Monday, May 21, 2012

`single-row subquery returns more than one row` error unclarity

I've got two tables.
The first one hold a type and the second one the value of this type.
In my example if there are more values 'john' as 'first_name' i get:single-row subquery returns more than one row



SELECT DISTINCT id FROM name WHERE id=(
SELECT id FROM name WHERE text1='first_name' INTERSECT
SELECT name_id FROM value WHERE text2='john');


I'm not very good with sql. I should use LEFT JOIN or something like that but it's not really clear to me how i should do this.





No comments:

Post a Comment