-
SQL Join? ***Resolved***
I have the following problem:
a searchstring seperared by "+" or ",". Something like:
me+you+we
Table:
Index IDCode name
1 1 we
2 1 me
3 2 me
4 2 you
5 2 we
6 3 we
7 3 you
I want to select only the IDCode that has all the names from the string. I have created some code to do this, but it is rather long. Is it possible to create a query who can do this and how?
Thanks for the answer,
danielsan
-
this should do it:
select * from table
where idcode in (select idcode from table where name = "me")
and idcode in (select idcode from table where name = "you")
and idcode in (select idcode from table where name = "we")
-
..and if you just want the idcodes change the first line to:
select distinct idcode from table
-
sorry, but that didn't work...
-
it worked for me, did you change the table name/field names to what you have in you database?
what code did you use to run the SQL?
-
Sorry, my faliure. The error handler killed the sql-syntax error. I forgot a space somewhere.
Thank you for taking the time to help me.
Regards,
danielsan