0

Say, this is my php array.

postids = Array
(
    [0] => 2172
    [1] => 383
    [2] => 2915
    [3] => 677
    [4] => 1289
    [5] => 1654
    [6] => 2252
    [7] => 2366
    [8] => 2998
    [9] => 2442
    [10] => 1246
)

Now in mysql table (t1) looks like this.

|postid|type|switch|
|1|A|0|
|2|A|1|
|3|A|0|
...
|383|A|0|
...
|1246|A|1|
...
|2172|A|1|
...
|2442|A|0|

So, I want to select postid of type 'A' where switch = 1 and order by my php array and includes post ids from my array.

so, is there any query like

select postids from t1 where type = 'A' and switch = 1 and postids = {<?php echo postids; ?>}

How do I achieve this?

J Doe
  • 3
  • 2

1 Answers1

0

You can use logical conditions in the WHERE,

           SELECT * FROM table WHERE type='A' AND switch='1' 
Zack Heisenberg
  • 395
  • 5
  • 11