Your cart is currently empty!
MySQL: Select From Where?
Select from table
SQL
x
1
1
SELECT * FROM some-tbl;
Select from another query
SQL
1
1
1
SELECT * FROM (SELECT * FROM some-tbl) AS some-other-tbl;
SQL
1
1
1
WITH some-other-tbl AS (SELECT * FROM some-tbl) SELECT * FROM some-other-tbl;
Save query to a variable, and use that variable with another select
SQL
1
3
1
SELECT id INTO @somevar FROM some-tbl WHERE id = 2;
2
SELECT * FROM some-other-tbl WHERE someid NOT IN (@somevar);
3
SELECT * FROM some-other-tbl WHERE someid = @somevar;
Using the results of another query as a condition
SQL
1
1
1
SELECT * FROM some-tbl WHERE xxx IN (SELECT xxx FROM some-other-table);
Leave a Reply