Reputation: 1365
I have this in my database:
id | column1
1 | ab
2 | cd
3 | cd
4 | ef
5 | cd
6 | ab
And I would like to get either ids :(1,6) or (2,3,5) or (4) but it has to have the same column1 name
I don't have a specific column1 name to search.
I want something that does the same thing as:
row=SELECT column1 FROM table LIMIT 1
row2=SELECT id FROM table WHERE column1=row[0].column1
but in one query, is that possible?
Upvotes: 0
Views: 30
Reputation:
SELECT id
FROM table
INNER JOIN
table
AS table2
ON table.column1=table2.column1
is probably the nearest you are going to get then you just use a WHERE clause such as WHERE table.column1='ab'
Upvotes: 0
Reputation: 624
You can nest SQL queries
row= SELECT id
FROM table
WHERE column1=(SELECT column1 FROM table LIMIT 1)
Upvotes: 1