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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T17:49:22+00:00 2026-05-23T17:49:22+00:00

I am fairly new with advanced MySQL commands, I have database tables with multiple

  • 0

I am fairly new with advanced MySQL commands, I have database tables with multiple relationships. I have an advanced search feature that must match Keywords to a few fields (most being in the Assets table but a couple in the User table). When I execute the following Query for desk it returns the same row multiple times, while it should do it once.

 SELECT 
   a.id, a.asset_id, a.name, a.serial_number, a.category_id, a.status_id, a.user_id, a.location_id 
 FROM 
   assets a, users u 
 WHERE 
  (a.asset_ID LIKE '%desk%' OR a.name LIKE '%desk%' OR (u.first_name LIKE '%desk%' OR u.last_name LIKE '%desk%')) AND 
  a.serial_number LIKE '%%' AND 
  a.category_id='2' 
 LIMIT 25 OFFSET 5450 
  • 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-23T17:49:23+00:00Added an answer on May 23, 2026 at 5:49 pm

    You have a cartesian product in your query. You should JOIN assets and users, e.g. with

    WHERE a.user_id = u.id
    

    or like this

    FROM assets a JOIN users u ON a.user_id = u.id
    

    UPDATE: Your comment shows that you actually want to “left outer join” the users table. This means, that all assets are in the result set regardless if there exists a matching user:

    FROM assets a LEFT OUTER JOIN users u ON a.user_id = u.id
    

    Read more about joining tables here: http://dev.mysql.com/doc/refman/5.5/en/join.html

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

Sidebar

Related Questions

I am fairly new to the more advanced database features, such as functions, but
Fairly new to database schema (plan to use SQLite). Having said that, I'm thinking
fairly new iPhone developer here. Building an app to send RS232 commands to a
I fairly new to JQuery and perhaps trying to achieve something that might be
I am fairly new to Emacs and I have been trying to figure out
I'm fairly new to asp.net and especially LINQ and SQL. Say I have a
I'm fairly new to Silverlight. I have an AutoCompleteBox which is filled with Data
I'm fairly new to advanced C++ program techniques such as templates, but I am
I'm fairly new to Rails and am writing a login form. I have used
I am fairly new to development, and Visual Studio 2010. I have a solution

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.