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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T01:37:44+00:00 2026-06-04T01:37:44+00:00

I am having trouble sorting out a query (making me nuts) if you look

  • 0

I am having trouble sorting out a query (making me nuts) if you look at the SQL below, notice the and/or. I need to essentially combine the images for the artist in 2 categories into one call BUT if I use the below sql I get all of the images in the first category as well as all the images from every artist in the second category rather than the ones for the particular artist. If you use an AND call it only gets images in both. So basically hopefully this made sense. All help is appreciated.

SELECT i.img_name, i.ordered_by, i.img_description, a.artist_path_name, a.artist_id, a.artist_dir, a.artist_name, a.first_name, a.last_name, a.artist_titletag, a.artist_metadesc, a.artist_metakey, ck.catKey_id, ck.keyword
        FROM images AS i JOIN artists AS a USING (artist_id)
        JOIN img_cat_table AS imc USING (img_id)
        JOIN catKeys AS ck USING (catKey_id)
        WHERE artist_name = 'j' AND catKey_id = 5 OR catKey_id = 1
  • 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-04T01:37:45+00:00Added an answer on June 4, 2026 at 1:37 am

    if you are using both AND/OR then you will want to use parentheses to determine the order

    WHERE (artist_name = 'j') AND (catKey_id = 5 OR catKey_id = 1)
    

    Or even use the following WHERE clause:

    WHERE (artist_name = 'j') AND (catKey_id IN (5, 1))
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm having trouble with sorting out a query for the following: Data: Column1 Column2
I having trouble in my sql query .Please see my example As u see,
I'm having a little bit of trouble sorting out the paging scenario with a
I'm having trouble printing out a MergeSort. I need help printing out each step
I`m having trouble trying to optimize this query with OVER (PARTITION BY ...) because
im having trouble figuring out how to bind mouseout() to my entire nav bar
I am having trouble sorting an array that includes undefined elements (a sparse array)
I´m having a little bit of trouble sorting a way to manage automatic resolved
Having trouble looping through multiple rows in a SQL table and getting the info
Having trouble with this -- a couple of other related posts out there, but

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.