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
Select Key=Value from a SQL WHERE clause
Moderator: General Moderators
-
markjohnson
- Forum Newbie
- Posts: 15
- Joined: Sat Feb 07, 2009 8:36 pm
Re: Select Key=Value from a SQL WHERE clause
Can't you get them from where this sql query was created?
-
markjohnson
- Forum Newbie
- Posts: 15
- Joined: Sat Feb 07, 2009 8:36 pm
Re: Select Key=Value from a SQL WHERE clause
Some of these queries would be saved separately. I would like to fetch the saved queries and extract some of the key fields from WHERE clause and their values.
Re: Select Key=Value from a SQL WHERE clause
You'll need to find (or build) an sql parser then.