How to ignore lines in sql query which specific id php

2633 views php
0

Hello Stackoverflow masters, i have a simply shop with php, i need to ignore some products in shop on manage page, how to possible to make ignore in query sql? my query looks atm like this: $query = "SELECT a.*, a.user as puser, a.id as pid, b.date as date, b.price as price, b.job_id as job_id, b.masterkey as masterkey FROM table_shop a INNER JOIN table_shop_s b ON a.id = b.buyid WHERE b.payok = 1 ORDER BY buyid";

im need to ignore list with product_id = "3","4" from table "table_shop_s" in this query

answered question

SELECT a.*, a.user as puser, a.id as pid, b.date as date, b.price as price, b.job_id as job_id, b.masterkey as masterkey FROM table_shop a INNER JOIN table_shop_s b ON a.id = b.buyid WHERE b.payok = 1 and b.product_id not in(3,4) ORDER BY buyid;

2 Answers

1

WHERE b.payok = 1 AND tablename.product_id != 3 AND tablename.product_id != 4

posted this
8

Simply use NOT IN (to ignore specific pids), with AND logical condition. Use the following:

$query = "SELECT a.*, 
                 a.user as puser, 
                 a.id as pid, 
                 b.date as date, 
                 b.price as price, 
                 b.job_id as job_id, 
                 b.masterkey as masterkey 
          FROM table_shop a 
          INNER JOIN table_shop_s b ON a.id = b.buyid 
          WHERE b.payok = 1 
            AND a.id NOT IN (3,4) 
          ORDER BY buyid";

posted this

Have an answer?

JD

Please login first before posting an answer.