#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2010
    Posts
    7
    Rep Power
    0

    Select Key=Value from a SQL WHERE clause


    Hi,

    I am programming in PHP and 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
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2016
    Posts
    21
    Rep Power
    0
    Code:
    ([A-Z_]+ ?=\d+)|([A-Z_]+ IN \(.*\))
    with /m/g options.

IMN logo majestic logo threadwatch logo seochat tools logo