Jump to content

Select Key=Value from a SQL WHERE clause


markjohnson

Recommended Posts

Hi,

 

I have a SQL statement:

$sql='SELECT PROPID, ADDRESS_1, ADDRESS_2, TOWN, POSTCODE1, POSTCODE2, BEDROOMS, BATHROOMS, RECEPTIONS, PRICE, TRANS_TYPE_ID FROM properties WHERE TRANS_TYPE_ID=2 AND BEDROOMS =3 AND PROP_SUB_ID IN (1,2,3,4,5,6,21,22,23,24,27,30,95,128,131) ORDER BY DATE_ADDED, PROPID DESC';

 

I want to be able to get the fields and their corresponding values as such:

 

$result['TRANS_TYPE_ID']=2;

$result['BEDROOMS']=3;

 

And then capture the values in PROB_SUB_IN IN(*)

 

How can I do this?

 

Any help will be greatly appreciated. Thanks

Link to comment
https://forums.phpfreaks.com/topic/250130-select-keyvalue-from-a-sql-where-clause/
Share on other sites

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.