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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T01:50:52+00:00 2026-05-19T01:50:52+00:00

Ok this (truncated query) runs fine. Got some expert advice a month ago to

  • 0

Ok this (truncated query) runs fine. Got some expert advice a month ago to fix it.

SELECT * FROM artWork WHERE art_id in (
    SELECT art_id FROM artWork AS a INNER JOIN userPrefs AS u ON ((
      ((u.media_oil='1' AND a.media_oil='1') OR 
       (u.media_acrylic='1' AND a.media_acrylic='1') OR 
       (u.media_wc='1' AND a.media_wc='1') OR 
       (u.media_pastel='1' AND a.media_pastel='1')) 

       etc, etc........................................

   WHERE a.artist_id NOT EXISTS (
        SELECT * FROM removeList AS r 
        WHERE r.artist_id = a.artist_id 
          AND r.user_id ='$user_id') 
          AND  a.make_avail='1' 
          AND a.cur_select='1' 
          AND u.user_id='$user_id' 
          AND ((u.pref_painting='1' AND a.pref_painting='1') OR 
               (u.pref_photo='1' AND a.pref_photo='1') OR 
               (u.pref_paper='1' AND a.pref_paper='1') OR 
               (u.pref_print='1' AND a.pref_print='1') OR 
               (u.pref_draw='1' AND a.pref_draw='1') OR 
               (u.pref_sculp='1' AND a.pref_sculp='1') OR 
               (u.pref_install='1' AND a.pref_install='1') OR 
               (u.pref_vid='1' AND a.pref_vid='1') OR 
               (u.pref_public='1' AND a.pref_public='1') OR 
               (u.pref_indef='1' AND a.pref_indef='1'))
    ) ORDER BY date_submit DESC

But now I need to exclude certain rows that may be in another 2 column (user_id & artist_id) child table: ‘removeList’. So I am trying without success to what amounts to a “triple join” (look for the code around ‘NOT EXISTS’):

SELECT * FROM artWork WHERE  art_id in (
    SELECT art_id FROM artWork AS a INNER JOIN userPrefs AS u ON ( 
             (((u.media_oil='1' AND a.media_oil='1') OR 
               (u.media_acrylic='1' AND a.media_acrylic='1') OR 
               (u.media_wc='1' AND a.media_wc='1') OR 
               (u.media_pastel='1' AND a.media_pastel='1')) 

               etc, etc........................................


    WHERE a.artist_id NOT EXISTS (
        SELECT * FROM removeList AS r 
        WHERE r.artist_id = a.artist_id AND r.user_id ='$user_id'
    ) 
    AND  a.make_avail='1' 
    AND a.cur_select='1' 
    AND u.user_id='$user_id' 
    AND (( u.pref_painting='1' AND a.pref_painting='1') OR 
         ( u.pref_photo='1' AND a.pref_photo='1') OR 
         ( u.pref_paper='1' AND a.pref_paper='1') OR 
         ( u.pref_print='1' AND a.pref_print='1') OR 
         ( u.pref_draw='1' AND a.pref_draw='1') OR 
         ( u.pref_sculp='1' AND a.pref_sculp='1') OR 
         ( u.pref_install='1' AND a.pref_install='1') OR 
         ( u.pref_vid='1' AND a.pref_vid='1') OR 
         ( u.pref_public='1' AND a.pref_public='1') OR 
         ( u.pref_indef='1' AND a.pref_indef='1') )  
    ) ORDER BY date_submit DESC

Am I reaching too far here? Is there a better approach I am overlooking. Thanks to all.

  • 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-19T01:50:52+00:00Added an answer on May 19, 2026 at 1:50 am

    NOT EXISTS shouldn’t have a column name before it. remove the a.artist_id from before the not exists.

    So the relevant line would say

    WHERE NOT EXISTS (
        SELECT * FROM removeList AS r 
        WHERE r.artist_id = a.artist_id AND r.user_id ='$user_id'
    )
    

    Not sure where you’re using this query, but its also recommended to parameterize your queries to prevent sql injections.

    Hope this helps!

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following query that running in SQLyog SELECT * FROM mytable WHERE
This morning I truncated my transaction before it's hourly backup. Since I truncated the
relocation truncated to fit: R_X86_64_PC32 against `.bss' I'm getting this linker error in g++
When I run a query through DBslayer http://code.nytimes.com/projects/dbslayer the floating point results are truncated
I am using following query to insert some large text data : internal static
I need to return my result set in XML and this works fine, but
I am trying to concatenate results of some string data in a query using
I have a table which stores data out of a complex query. This table
I query my mySql database table and retrieve text strings that look like this:
When I SELECT a Geometry column with AsText() , the returned value is truncated

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.