I require help to design a sql statement to get some specific dataset. This sql statement I need to run using php script.
Let me first describe the table structure. Table 'tblservicedetails' contains the following fields:
Expand|Select|Wrap|Line Numbers
- 'srv_id' INT(11) NOT NULL AUTO_INCREMENT PRIMARY KEY ,
- 'srv_mcid' INT(6) NOT NULL ,
- 'srv_jobcodeid' INT(2) NOT NULL ,
- 'srv_date' INT(11) NOT NULL DEFAULT 0
- ......
Expand|Select|Wrap|Line Numbers
- SELECT srv_id, srv_mcid, srv_jobcodeid, srv_date
- FROM tblservicedetails
- WHERE srv_mcid IN (264, 460, 870) AND srv_jobcodeid IN (13, 14)
Expand|Select|Wrap|Line Numbers
- srv_id | srv_mcid | srv_jobcodeid | srv_bkdate
- 11 | 870 | 13 | 1254790800
- 16 | 870 | 14 | 1264361400
- 178 | 264 | 14 | 1265997600
- 242 | 460 | 14 | 1272153600
- 245 | 264 | 13 | 1267299000
Expand|Select|Wrap|Line Numbers
- srv_id | srv_mcid | srv_jobcodeid | srv_bkdate
- 16 | 870 | 14 | 1264361400
- 242 | 460 | 14 | 1272153600
- 245 | 264 | 13 | 1267299000
with srv_jobcodeid as 13 or 14.
What should be the sql statement that can provide this above result set?
In where condition the list of values for srv_mcid will vary and actually it will be populated dynamically in php.
I need your help to design the sql statement. I am not very sure if I need to write a subquery for this.