Jump to content

Mysql selecting the particular value.


lovesmith

Recommended Posts

I have "AvailableIn" field in the table Music. The Field might contain the value either of one or all of them

"CD,VCD,CASSETTE" or "CD, VCD" or so on. I have form in my website where user can select to search a album, they got combobox where they can choose whether they want to search in CD, VCD or in DVD.

If i use LIKE in query like this. "SELECT album FROM table MUSIC WHERE AvailableIn LIKE "%CD%", it will yield the VCDs AS well. This has been difficult for me as the audio types are in same field with comma separated. Can anybody help me please!

Link to comment
https://forums.phpfreaks.com/topic/85666-mysql-selecting-the-particular-value/
Share on other sites

I have "AvailableIn" field in the table Music. The Field might contain the value either of one or all of them

"CD,VCD,CASSETTE" or "CD, VCD" or so on. I have form in my website where user can select to search a album, they got combobox where they can choose whether they want to search in CD, VCD or in DVD.

If i use LIKE in query like this. "SELECT album FROM table MUSIC WHERE AvailableIn LIKE "%CD%", it will yield the VCDs AS well. This has been difficult for me as the audio types are in same field with comma separated. Can anybody help me please!

You should just create a separate column for audio types.

 

Otherwise, you'll have to get them with explode("," $AvailableIn); and then check them. Easier to just create a separate column.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.