Jump to content

Searching Within A Field


hansman

Recommended Posts

Here is my code

 

SELECT Companies.Name, Companies.Address, Companies.Website, Companies.Email, Companies.Services, Companies.Fax, Companies.Phone, Companies.ZipCodes, Zips.ZipCode, Zips.StateAbbr FROM Companies, Zips WHERE Companies.ZipCodes LIKE \%'$zip'%\ 

 

i get the error

 

You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '\%'10511'%\' at line 1

summed up:

 

SELECT Companies.Name, 
Companies.Address, 
Companies.Website, 
Companies.Email, 
Companies.Services, 
Companies.Fax, 
Companies.Phone, 
Companies.ZipCodes, 
Zips.ZipCode, 
Zips.StateAbbr 
FROM Companies
LEFT JOIN Zips ON <place_your_condition_for_joining_here>
WHERE Companies.ZipCodes LIKE '%$zip%'

 

The condition that fenway wants to point out is to avoid unnecessary pairing of records from one table to another.

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.