Hello I'm having a problem.
I want to search values in the name column using the where clause. Example table is this with values stored.
table1
--------------------------
id | name | anotherid
--------------------------
1 | name1 | 1
2 | name2 | 1
2 | name2 | 2
I have textboxes that I can change how many they appear. For example I have two textboxes. The value on textbox one is 'name1' and the second is 'name2'
My query must find those two values in table1 and, when they're found, their anotherid column must be the same also.
From the first table, All I want to get is this:
table1
--------------------------
id | name | anotherid
--------------------------
1 | name1 | 1
2 | name2 | 1
However when a situation like this appears and I still have two textboxes with the same values:
table1
--------------------------
id | name | anotherid
--------------------------
1 | name1 | 1
2 | name2 | 1
2 | name2 | 2
3 | name3 | 1
The result must be empty.
Now back to the first table. I used this code.
SELECT * FROM `table1` WHERE name = "name1" and name = "name2"
and
SELECT * FROM `table1` WHERE name = "name1" and name = "name2" group by anotherid
but all I get are empty results.
How do you do this?