MySqlTalk.com  

Go Back   MySqlTalk.com > MySQL > SQL syntax
User Name
Password
FAQ Members List Calendar Search Today's Posts Mark Forums Read


Reply
 
Thread Tools Search this Thread
Old 01-18-2005, 04:22 AM   #1
AllenGarner
Junior Member
 
Join Date: Jan 2005
Posts: 8 AllenGarner is on a distinguished road
selecting * where zipcode in this array

I need to be able to do the following:

"select * where `field1` Like 'this value' AND `field2` LIKE 'this value' AND `field3` LIKE 'this value' AND `field4` LIKE 'any of the values in this array'"

the problem I had was that I tried various AND/OR combinations but kept getting unwanted records. Like the value in field4 would be one of the values in the array but the values in say field1 or field two would not be the value in the field1 Like 'this value' part. i need to restrict the values to the given 'this value' part for all other fields and still get results for the field for in this array part. Can anyone help? Pleeeeaaassse?

the array is an array in php and I want it to check the values in the array and if it exists in the array include it in the results as long as the other fields maintain there restrictions
the array is in the form $array [0] => 'some value'
[1] => 'somevalue'
[2] => 'some value'
etc..............

Last edited by AllenGarner : 01-18-2005 at 05:02 AM.
AllenGarner is offline   Fork this post Reply With Quote
Old 01-18-2005, 05:33 AM   #2
AllenGarner
Junior Member
 
Join Date: Jan 2005
Posts: 8 AllenGarner is on a distinguished road
Re: selecting * where zipcode in this array

This was as close as I could come to making sense of a query for this
however it doesn't work lol... anyone have any ideas?

"SELECT * FROM `autos` WHERE `make` LIKE '" . $_POST['make'] . "' AND `model` LIKE '" . $_POST['model'] . "'
AND `price` BETWEEN '" . $_POST['lowprice'] . "' AND '" . $_POST['hiprice'] . "' AND `condition` LIKE '" . $_POST['condition'] . "'
HAVING `zip` in (" . $searchzips . ")
ORDER BY `price`";


the last part after the having clause is an array variable containing a result set retrieved by a select statement with all the zipcodes within a certain radius of the given zip

Last edited by AllenGarner : 01-18-2005 at 05:52 AM.
AllenGarner is offline   Fork this post Reply With Quote
Old 01-18-2005, 06:37 AM   #3
AllenGarner
Junior Member
 
Join Date: Jan 2005
Posts: 8 AllenGarner is on a distinguished road
Re: selecting * where zipcode in this array

I figured it out thanks anyway
AllenGarner is offline   Fork this post Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Search Array Column KidGeek SQL syntax 1 10-20-2004 04:01 PM



All times are GMT -4. The time now is 06:26 AM.



Powered by: vBulletin, Copyright ©2000 - 2008, Jelsoft Enterprises Limited.
Google
  Web http://www.mysqltalk.com
DISCLAIMERS:
1. We have no commercial interest in this site.
Banner Ads and Subscriptions will only be used to help pay for hosting and maintenance costs.
2. MySQLTalk.com is NOT affiliated with MySQL AB in any way.
3. MySQLTalk.com is NOT endorsed by MySQL AB in any way.
4. Please do not post any content that is harmful to MySQL or MySQL AB, meaning no misleading or obsolete information will be tolerated.
Well-founded constructive criticism meant to help the community is permitted.
5. This website is founded with the goal of improving the MySQL community.
We not only tolerate newbies, we encourage them.
Please do not ask newbies to "read the manual".