genre
---
genre_id
genre_title
xref_music_genre
---
music_id
genre_id
Если человек вводит запрос вида: "trance and house", то как правильно делать в таком случае выборку, чтобы в результате были выведены все треки, в жанрах которых встречаются слова из этого запроса? В данном случае должны вывестись все треки из жанра house и trance.
select music_id
from xref_music_genre
where genre_id IN (5,7)
group by music_id
HAVING count(genre_id)=2
select distinct param_1 from table where param_3 is not null;
select * from table where param_1 IN (явное перечисление значений из прошлого запроса);
select * from table where param_1 IN (select param_1 from table where param_3 not null);
тоже будет работать, хоть и медленнее A variable-length string. M represents the maximum column length in characters. In MySQL 5.0, the range of M is 0 to 255 before MySQL 5.0.3, and 0 to 65,535 in MySQL 5.0.3 and later. The effective maximum length of a VARCHAR in MySQL 5.0.3 and later is subject to the maximum row size (65,535 bytes, which is shared among all columns) and the character set used. For example, utf8 characters can require up to three bytes per character, so a VARCHAR column that uses the utf8 character set can be declared to be a maximum of 21,844 characters. See Section D.7.4, “Limits on Table Column Count and Row Size”.dev.mysql.com/doc/refman/5.0/en/string-type-overvi...
MySQL stores VARCHAR values as a 1-byte or 2-byte length prefix plus data. The length prefix indicates the number of bytes in the value. A VARCHAR column uses one length byte if values require no more than 255 bytes, two length bytes if values may require more than 255 bytes.
select
price.*, tovar.tovar_name
from price
join tovar on tovar.tovar_id = price.tovar_id
where price.date = (select MAX(price2.date) from price as price2 where price2.tovar_id=price.tovar_id )
order by price.price