MySql select by column value. Separeta operator for columns.
Posted
by andy
on Stack Overflow
See other posts from Stack Overflow
or by andy
Published on 2010-03-25T09:32:19Z
Indexed on
2010/03/25
9:33 UTC
Read the original article
Hit count: 368
mysql
|mysql-query
Hi all, i have a mysql table like this
+-----+---------+-----------+-----------------+-------+
| id | item_id | item_type | field_name | data |
+-----+---------+-----------+-----------------+-------+
| 258 | 54 | page | field_interests | 1 |
| 257 | 54 | page | field_interests | 0 |
| 256 | 54 | page | field_author | value |
+-----+---------+-----------+-----------------+-------+
And, I need build query like this
SELECT * FROM table WHERE
`field_name`='field_author' AND `field_author.data` LIKE '%jo%'
AND
`field_name`='field_interests' AND `field_interests.data`='0'
AND
`field_name`='field_interests' AND `field_interests.data`='1'
This is sample query. MySql can't do queries like that. I mean than SELECT * FROM table WHERE name='jonn' AND name='marry' will return 0 rows.
Cant anybody help me.
Thanks.
© Stack Overflow or respective owner