Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

Troubleshooting
Research
Professional Opinions
Ask a Question
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE

troubleshooting Question

String multiple values in WHERE clause

Avatar of MDauphinais1
MDauphinais1 asked on
PHPMySQL Server
6 Comments1 Solution506 ViewsLast Modified:
I have a php variable "$song[0]" that is already formatted like this: "Artist - Title".

I need to search for a matching record within a database that stores the artist and titles in seperate columns. To do this, I created this query:

"SELECT s.id, s.artist, s.title, s.picture, s.buycd, s.label, s.composer, s.rating, s.numvotes, s.duration, s.date_played FROM songlist s WHERE ((s.artist & ' - ' & s.title) = '$song[0]') LIMIT 0,1"

The problem is that instead of pulling the correct record, it just pulls the first record in the table. What is the correct way to write this?