SQL Query
WITH z0 AS (SELECT * FROM meme m0 WHERE m0.rid="president_order" AND m0.qnt>=20 AND m0.qnt<=30) SELECT * FROM meme m0 WHERE m0.rid="spouse" AND m0.qnt!=0 AND m0.aid IN (SELECT aid FROM z0) UNION ALL SELECT * FROM z0;
Results
ARBQ
benjamin_harrisonspouselavinia_scott_harrison1
calvin_coolidgespousegrace_anna_goodhue_coolidge1
chester_arthurspouseellen_lewis_herndon_arthur1
grover_clevelandspousefrances_folsom_cleveland1
james_garfieldspouselucretia_rudolph_garfield1
theodore_rooseveltspousealice_hathaway_lee_roosevelt1
theodore_rooseveltspouseedith_kermit_carow1
warren_hardingspouseflorence_kling_harding1
william_mckinleyspouseida_saxton_mckinley1
william_taftspousehelen_herron_taft1
woodrow_wilsonspouseedith_wilson1
woodrow_wilsonspouseellen_louise_axson1
james_garfieldpresident_orderfirst20
chester_arthurpresident_orderfirst21
grover_clevelandpresident_orderfirst22
benjamin_harrisonpresident_orderfirst23
grover_clevelandpresident_ordersecond24
william_mckinleypresident_orderfirst25
theodore_rooseveltpresident_orderfirst26
william_taftpresident_orderfirst27
woodrow_wilsonpresident_orderfirst28
warren_hardingpresident_orderfirst29
calvin_coolidgepresident_orderfirst30
Memelang SQL Demo
This is demonstration of translating Memelang to SQL for querying relational databases. See the PHP code in GitHub. A Python version is coming soon. Example queries:
Show all data in this DB.
qry.all
All about George Washington.
george_washington
Who were children of the presidents?
.child
Which presidents were members of the Whig party?
.party:whig
Which presidents attended Harvard?
.college:harvard
Which presidents were born before 1820?
.birth.year:ad<1820
Which presidents attended Columbia and were lawyers?
.college:columbia .lawyer
Who were the twentieth through thirtieth presidents?
.president_order>=20 .president_order<=30
Which presidents attended a college that was not Harvard?
.college .college:harvard=f
Which presidents did not have children?
.president_order .child=f
Who were the spouses of the twentieth through thirtieth presidents?
.president_order>=20 .president_order<=30 .spouse
Use qry.all to return all memes related to the matching As.
.college:harvard .college:columbia qry.all
Get all about James Carter as well as Ronald Reagan.
james_carter; ronald_reagan
Which presidents were lawyers that attended Harvard or William and Mary?
.lawyer .college:harvard=t1 .college:william_and_mary=t1
What were the professions of the presidents?
?profession
Which presidents has children that became presidents?
.child.president_order