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 7040657
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T01:56:39+00:00 2026-05-28T01:56:39+00:00

I am making a MySQL query where I want to retrieve an ID but

  • 0

I am making a MySQL query where I want to retrieve an ID but only if I find a match for it in all the rows which I specify in the query.

Table: view_layout_rows

ID    owner    rows
___________________
49    1        2
50    1        2




Table: view_layout_rows_columns

ID    row    columns
___________________
49    1      5
49    2      4
50    1      5
50    2      5



SELECT vlr.id
FROM view_layout_rows vlr
INNER JOIN view_layout_rows_columns vlrc
ON vlr.id = vlrc.id 
WHERE vlr.rows = 2
AND (vlr.owner = 0 OR vlr.owner = 1)

AND all of the following conditions should be satisfied:

(vlrc.row = 1 AND vlrc.columns = 5) 
(vlrc.row = 2 AND vlrc.columns = 5)

Only ID 50 should be returned. 49 should NOT be returned as it only satisfies the first of the final two clauses.

How might I go about this?
(Please note, I asked this question previously but my requirement was unclear. Second attempt.)
Thanks in advance for any suggestions.

  • 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-05-28T01:56:40+00:00Added an answer on May 28, 2026 at 1:56 am

    Double join to the rescue! 🙂

    SELECT vlc.* 
    FROM view_layout_rows vlc
    INNER JOIN view_layout_rows_columns vlrc1 ON vlrc1.id = vlc.id
    INNER JOIN view_layout_rows_columns vlrc2 ON vlrc2.id = vlc.id
    WHERE vlrc1.row = 1 AND vlrc1.columns = 5
      AND vlrc2.row = 2 AND vlrc2.columns = 5
    
      /* imported from original query */
      AND vlr.rows = 2
      AND (vlr.owner = 0 OR vlr.owner = 1);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to build a mySQL query, which returns all nodes in a graph
I want to making a MySQL query that gets a link from table1 and
**categories** mysql table id|category_name **listings** mysql table id|listing_title|category_id I want to list all categories
I'm making a table of games and times but I want to use javascript
I want to retrieve all rows of a particular user with limit 0,x.. So
I'm experimenting by making a social network from scratch in PHP/MySQL, but I'm having
I'm modelling MySQL database for an website. I'm now making 'people' table, and deciding
I am making a PHP web Application in which i am using MySQL as
I want to create a table for making a comment box. I was told
I'm making a comment box. but i want so when people click submit comment,

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.