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
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.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.