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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T13:03:49+00:00 2026-06-11T13:03:49+00:00

Basically, my 0 OR 0 is returning 1 – that’s not really what I

  • 0

Basically, my 0 OR 0 is returning 1 – that’s not really what I wanted 🙂 I’m not really sure why because if I select 0 OR 0 I get 0..

I think this could be because is_premium_dealer is an enum(‘0′,’1’) rather than a bool (don’t ask me why, I didn’t design this database!)

Does anyone know if this is because of the ENUM, and if so how I’d cast it to an integer?

Thanks in advance!
John.

SELECT is_premium_dealer, company_name,
(SELECT COUNT(*) FROM adverts WHERE user_id = users.id AND is_archived = 0) AS innerquery,
((SELECT COUNT(*) FROM adverts WHERE user_id = users.id AND is_archived = 0 AND is_deleted = 0) > 0 OR is_premium_dealer = 1) AS logicissue
FROM `user_profiles_dealers` 
LEFT JOIN `users` ON user_profiles_dealers.user_id = users.id 
LEFT JOIN `counties` ON user_profiles_dealers.county_id = counties.id 
LEFT JOIN `countries` ON user_profiles_dealers.country_id = countries.id 
WHERE (users.is_active=1) 
AND (((SELECT COUNT(*) FROM adverts WHERE user_id = users.id AND is_archived = 0 AND     is_deleted = 0) > 0) OR is_premium_dealer > 0) 
AND company_name like '%autocraft%' limit 5\G

The result:

*************************** 1. row ***************************
is_premium_dealer: 0
company_name: A Company
innerquery: 0
logicissue: 1
1 row in set (0.00 sec)
  • 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-11T13:03:50+00:00Added an answer on June 11, 2026 at 1:03 pm

    The answer was to wrap is_premium_dealer in the BINARY() function which seems to cast a string or anything into a binary value which can be evaluated as expected.

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

Sidebar

Related Questions

I have this Linq to SQL query sequence that is basically returning a search
Not quite sure if I asked correctly, but basically I have an array that
Can I have some help in improving this linq. I'm basically returning speakers from
Basically my question is this, why is: String word = unauthenticated; word.matches([a-z]); returning false?
ifstream::tellg() is returning -13 for a certain file. Basically, I wrote a utility that
Basically I have a function that roughly looks like this and I need to
What i have is a union query that is returning two rows because of
Basically I need to get older version of a file in the repository without
Basically, I have a UIImageView that will loop through 8 PNGs over 0.5 seconds.
basically I want to validate whether or not a text box is a certain

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.