Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7844847
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T17:01:42+00:00 2026-06-02T17:01:42+00:00

tbl_pack_service; +——-+———+————+ | ps_id | pack_id | service_id | +——-+———+————+ | 1 | 1

  • 0
tbl_pack_service;
+-------+---------+------------+
| ps_id | pack_id | service_id |
+-------+---------+------------+
|     1 |       1 |          1 |
|     2 |       1 |          2 |
|     3 |       2 |          1 |
|     4 |       2 |          2 |
|     5 |       2 |          3 |
|     6 |       2 |          4 |
|     7 |       2 |          5 |
|     8 |       3 |          1 |
|     9 |       3 |          2 |
|    10 |       3 |          3 |
|    11 |       3 |          4 |
+-------+---------+------------+

ps_id is primary key
i am tying to make dynamic select list in php
i want a mysql query that can give service id which do not match with particular pack_id

like i have service_id 1,2,3,4,5
when i should select pack_id=1 then 3,4,5 should be displayed
and when i should select pack_id=2 then nothing should be displayed as it has all the 5 services.
thanks..

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-02T17:01:43+00:00Added an answer on June 2, 2026 at 5:01 pm

    There are a few ways to handle this. The easiest is with a NOT IN subquery:

    SELECT DISTINCT service_id
    FROM 
      tbl_pack_service
    WHERE service_id NOT IN (SELECT service_id FROM tbl_pack_service WHERE pack_id = 1)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I created a table tbl_Candidate , but I forgot to set the primary key
Taking in consideration a table tbl_users , I want to get a list of
I have a table tbl_a, with ID as a primary key, with columnns A1,B1,A2,B2
I have a table tbl_a, with ID as a primary key, with columnns GROUP_ID,DATE,LENGTH,VALID,CID
select * from tbl Is there an easy way to list all the column
if i have a table like this tbl_attributes --------------- id_attrib (auto incremented, primary key)
tbl_customer.id is the customer's id tbl_order.customer_id a query that will select all customers with
SELECT * FROM tbl_group_join tgj LEFT JOIN tbl_groups tg ON tg.group_id = tgj.group_id LEFT
SELECT * FROM tbl_houses WHERE (SELECT HousesList FROM tbl_lists WHERE tbl_lists.ID = '123') LIKE
SELECT * FROM tbl_order_head AS o INNER JOIN tbl_orders_log AS c ON o.PAYMENT_TRANSACTION_LOG_ID=c.TRANSACTION_ID WHERE

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.