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

  • Home
  • SEARCH
  • 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 3304246
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T21:02:30+00:00 2026-05-17T21:02:30+00:00

The exact query: SELECT coupon_coupons . code , coupon_coupons . discountType AS ‘type’, coupon_coupons

  • 0

The exact query:

SELECT
coupon_coupons.code,
coupon_coupons.discountType AS ‘type’,
coupon_coupons.discountAmount AS ‘amount’,
coupon_coupons.discountApplied AS ‘applied’,
coupon_coupons.description,
group_concat(coupon_targetsku.sku separator ‘;’) AS ‘targetsku’
FROM coupon_coupons
LEFT JOIN coupon_targetsku ON coupon_coupons.code = coupon_targetsku.code
WHERE coupon_coupons.code = ‘testCode’

coupon_coupons.code = primary key
coupon_targetsku.code = fk(coupon_coupons.code)

If the coupon_coupons.code is found in the database the query operates as expected, but when its not found the result set that is returned is one row with all NULL values. I’m guessing its something I’m doing wrong with the left join.

I would like this query to return zero rows if the code is not found.

I’m using mysql:
Server version 5.1.36-community-log
Protocol version: 10

Thanks in advance.

  • 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-17T21:02:30+00:00Added an answer on May 17, 2026 at 9:02 pm

    It’s good to use group by when using group_concat()

    SELECT coupon_coupons.code,
    coupon_coupons.discountType AS 'type',
    coupon_coupons.discountAmount AS 'amount',
    coupon_coupons.discountApplied AS 'applied',
    coupon_coupons.description,
    group_concat(coupon_targetsku.sku separator ';') AS 'targetsku' 
    FROM coupon_coupons
    JOIN coupon_targetsku ON coupon_coupons.code = coupon_targetsku.code 
    WHERE coupon_coupons.code = 'testCode'
    GROUP BY coupon_coupons.code
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

What's the query syntax to determine the exact version number of the MySQL server
Considering this MySQL query: SELECT someColumns FROM someTable WHERE someColumn IN ( value1, value2,
I have a bind in the SQL query SELECT * FROM users WHERE name
Suppose that I have a database query which looks like below - select name,
I have this MySql query: SELECT * FROM `tbl_prods` WHERE `id` IN ('58', '169',
How can I do this query with NHibernate select top 10 count(distinct classedition.createdby_id) as
I am calling a simple JOIN SQL on a mySQL database. The exact query
The query: SELECT users.* FROM users WHERE (lower(fname) || ' ' || lower(lname) LIKE
this is what i have SELECT node.nid AS nid, node.type AS node_type, product.* FROM
Exact Duplicate of: Getting the size (free,total) of a Windows Mobile phone drive using

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.