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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T17:47:26+00:00 2026-06-12T17:47:26+00:00

I need to do a Distinct search in the following query: $listings = $this->Listing->query(SELECT

  • 0

I need to do a Distinct search in the following query:

$listings = $this->Listing->query("SELECT DISTINCT(Listing.listnumber),Listing.*, ClientEvent.*, Client.*, UserLog.*, Agent.* FROM listings Listing
                        LEFT JOIN client_events ClientEvent ON ClientEvent.listnumber = Listing.listnumber
                        LEFT JOIN clients Client ON Client.clnt_id = ClientEvent.clnt_id
                        LEFT JOIN user_logs UserLog ON UserLog.ul_item_id = Listing.listnumber
                        LEFT JOIN agents Agent ON Agent.agnt_id = Listing.agnt_id
                        WHERE Listing.off_id = '{$off_id}' AND (UserLog.ul_type = 'listing.new_listing' OR Listing.listnumber LIKE '3330%')");

However, this gives me the correct result, but duplicates. I need DISTINCT results.

Any ideas?

  • 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-12T17:47:27+00:00Added an answer on June 12, 2026 at 5:47 pm
        $listings = $this->Listing->query("SELECT Listing.listnumber FROM listings Listing
                                LEFT JOIN client_events ClientEvent ON ClientEvent.listnumber = Listing.listnumber
                                LEFT JOIN clients Client ON Client.clnt_id = ClientEvent.clnt_id
                                LEFT JOIN user_logs UserLog ON UserLog.ul_item_id = Listing.listnumber
                                LEFT JOIN agents Agent ON Agent.agnt_id = Listing.agnt_id
                                WHERE Listing.off_id = '{$off_id}' AND (UserLog.ul_type = 'listing.new_listing' OR Listing.listnumber LIKE '3330%') group by Listing.listnumber");
    ----------------------
    Put your extar column not a tablename.*...
    
        $listings = $this->Listing->query("SELECT Listing.listnumber, colname1,.. FROM listings Listing
                                LEFT JOIN client_events ClientEvent ON ClientEvent.listnumber = Listing.listnumber
                                LEFT JOIN clients Client ON Client.clnt_id = ClientEvent.clnt_id
                                LEFT JOIN user_logs UserLog ON UserLog.ul_item_id = Listing.listnumber
                                LEFT JOIN agents Agent ON Agent.agnt_id = Listing.agnt_id
                                WHERE Listing.off_id = '{$off_id}' AND (UserLog.ul_type = 'listing.new_listing' OR Listing.listnumber LIKE '3330%') group by Listing.listnumber");
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Can I select like this? SELECT DISTINCT idClient, idAcc,Description FROM client, account WHERE (account.idCliente
Can anyone tell me whats wrong with this MySQL query ? select distinct(a.productId) from
how set distinct to this query return _dataContext.ProjectPictures.Include(Projects).Include(ProjectPictureTypes).Where(p => p.ProjectPictureTypes.Id == 1).ToList(); i need
I'm quite confused as to how I'd structure a query I need: select distinct
In my query I need to return distinct fields for my search. However the
Hi Programmers! Actually i need the distinct values from the List after adding some
I need to count all distinct values from table LDS where status = 'ok'
I need use this method with three distinct classes: Orders, Customers, Suppliers public void
Ok this is driving me nuts, I need to write an SQL query that
I am using the following query to get the results which i demonstrated SELECT

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.