Jump to content

[SOLVED] Mysql SELECT question...


nightkarnation

Recommended Posts

Hello, i was wondering what goes where i wrote *...in the following SQL Query

 

SELECT * FROM `apt_data` WHERE neighborhood = * AND weeklyRate <= 400

 

What i want is to query ALL the neighborhoods that are less or equal to 400 (i know that simply without placing neighborhood i will query it) but this comes from a much larger code connected to php/flash and i need to know how can i specify neighborhood = ALL/EVERY NEIGHBORHOOD on this query...

 

Thank u very much in advance!

Cheers,

Link to comment
Share on other sites

The thing is that this query recieves information from flash/php...

 

the real one is:

 

SELECT * FROM `apt_data` WHERE neighborhood = '$neighborhood' AND weeklyRate <= 400

 

And there's an option on flash that says: ALL NEIGHBORHOODS ... instead of a specific neighborhood...so how can i tell to the query to look for All Neighborhoods ?

Link to comment
Share on other sites

unkwntech do u mean this:

 

SELECT * FROM `apt_data` WHERE neighborhood = '%' AND weeklyRate <= 400

?

 

DarkWater ur not getting it, sorry for not being so clear...

 

On flash i have a Neighborhood combobox that has 4 options...

ALL NEIGHBORHOODS

Belgrano

Palermo

San Telmo

 

Now...if a user selects Belgrano then...

 

SELECT * FROM `apt_data` WHERE neighborhood = '$neighborhood' AND weeklyRate <= 400

works perfectly...

 

But if the user selectds ALL NEIGHBORHOODS...how can i tell $neighborhood before the query to = something that equals all neighborhoods

Link to comment
Share on other sites

As its been pointed out this is a better solution the using %

 

if($_POST['neighborhood'] == 'all')
{
  $sql = "SELECT * FROM `apt_data` WHERE weeklyRate <= 400";
}
else
{
  $sql = "SELECT * FROM `apt_data` WHERE neighborhood = '$neighborhood' AND weeklyRate <= 400"
}

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.