Created
April 15, 2015 08:17
-
-
Save oak-tree/04d1ba22547d9faaeb08 to your computer and use it in GitHub Desktop.
mysql key,value query with multiply keys
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| SELECT term_id,count(name) as counter FROM `tbl_term_character` | |
| WHERE | |
| (name="Size" && (value & b'10')) | |
| || | |
| (name="HeadColors" && (value & b'110')) | |
| group by term_id | |
| having counter = 2 |
Author
Author
with the name as well
select id,hebrewName from tbl_term as t1 join (SELECT term_id FROM tbl_term_character
WHERE
(name="Size" && (value & -1))
group by term_id
having count(name) = 1) as t2
ON t1.id = t2.term_id
where t1.hebrewName <> ""
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
combine it with the tbl_term
two options
IN
tbl_term_characterWHERE (name="Size" && (value & b'100')) || (name="HeadColors" && (value & b'110')) group by term_id having count(name) = 2) ORDER BYtbl_term.urlBestBigPhotoASCJoin
select id,hebrewName from tbl_term as t1 join (SELECT term_id FROM
tbl_term_characterWHERE
(name="Size" && (value & -1))
group by term_id
having count(name) = 1) as t2
ON t1.id = t2.term_id