MySQL - Select rows with id from another table
Discuss coding issues, and scripts related to PHP and MySQL.
-
PloMar
- Posts: 48
MySQL - Select rows with id from another table
I have the following Select in MySQL:
Code: Select all
$sql = "SELECT * FROM table_1 WHERE rank = 2 AND id IN(2, 5, 8)";
But the IDs (2, 5, 8, ...) must be from a Select from another table.
So, how can I select the rows from table_1 with the IDs from table_2?
MarPlo
Posts: 186
You can use multiple Select statements in the same SQL query.
Try this query, using a sub-select that selects the IDs.
Code: Select all
$sql = "SELECT * FROM table_1 WHERE rank = 2 AND id IN(SELECT id FROM table_2 WHERE condition)";
- Replace "condition" with the condition that you want to select the IDs from table_2.
Similar Topics
-
Multiple select for upload not working on mobile
JavaScript - jQuery - Ajax
First post
Plessant Coursesweb,
meight useless to ask but it seems this upload for picture-album is not working on my mobile-page
but on my computer I just...
Last post
Try to search on the internet for:
html multiple select upload mobile