Advertisement

04.01.2008 at 04:46AM PDT, ID: 23285368
[x]
Attachment Details
[x]
The Solution Rating System

With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.

  • The Grade of the Solution
  • The Zone Rank of the Expert Providing the Solution
  • The Number of Author and Expert Comments
  • The Number of Experts Contributing
  • The Feedback of the Community

Your Input Matters
Because of the way the system is set up, the most important variable in this equation is you. As a member of Experts Exchange, you are able to cast your vote on the quality of the solutions in regard to how complete, accurate, helpful and easy to understand each solution is. When you provide your feedback, each rating is adjusted accordingly. So, if you see a solution that has a poor rating that you think is a good solution, let us know by rating it. As you do, the rating will be adjusted and will become more accurate for other members of our site.

If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support.

Thank you!

9.4

Help us with this mysql query. It is returning duplicate results

Asked by chadhaajay in MySQL Server

Tags: , , , ,

Hello Experts,

We need your help regarding a complex mysql query. I've used the word complex as it is difficult for us to figure out the solution and we have tried all known approaches.

We have 3 tables as explain below.

tbl_products, tbl_orders, tbl_shipping

and fields of each table are

Table: tbl_products

product_id, INT(11), Primary Key
product_name, Varchar(100)
product_description, TEXT
product_status, Enum('pending','approved')

Table: tbl_orders

order_id, INT(11), Primary Key
order_details, TEXT
order_status, Enum ('shipped','pending')

Table: tbl_shipping

shipping_id, INT(11), PK
order_id, INT(11)
shipping_details, TEXT

Note: The field order_id is the relation between tbl_orders and tbl_shipping because tbl_shipping can contain many records with same order_id.

We need a query that would search all three tables for a given keyword and return the matching results (without any duplicate results) of records those are approved.

Sample data of these tables are:

Table: tbl_products

product_id | product_name | product_description | product_status
----------------------------------------------------------------
1 | Mobile Phone | This is a mobile phone from nokia company | approved
2 | Cars | I love this car | pending
3 | Music Player | iPod is a very nice music player | approved
4 | Calculator | This calculator is the best in market | approved

Table: tbl_orders

order_id | order_details | order_status
-------------------------------------
1 | mobile phone order is under processing | pending
2 | nokia mobile phone is being shipped | approved
3 | ipod order from smith | approved
4 | best mobile with calculator is shipped | approved

Table: tbl_shipping

shipping_id | order_id | shipping_details
--------------------------------------
1 | 2 | test data of mobile
2 | 2 | mobile phone
3 | 1 | bla bla bla
4 | 2 | ipod shipping details
5 | 3 | again test data
6 | 1 | bla ipod mobile bla

We need to have a query that will create relation between tbl_orders and tbl_shipping using the field order_id i.e. WHERE tbl_orders.order_id = tbl_shipping_order_id so that only those orders are included who are approved i.e. AND tbl_orders_order_status='approved'. This query has to search the text fields of al 3 tables for a give search keyword and display the records. Test keyword can be "mobile", "best" or "ipod".

Any help would be greatly appreciated.Start Free Trial
[+][-]04.01.2008 at 02:09PM PDT, ID: 21258116

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]04.01.2008 at 11:07PM PDT, ID: 21260470

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]04.02.2008 at 06:21AM PDT, ID: 21262709

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]04.03.2008 at 03:23AM PDT, ID: 21271003

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]04.03.2008 at 03:30AM PDT, ID: 21271041

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]04.06.2008 at 02:03PM PDT, ID: 21293142

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zone: MySQL Server
Tags: mysql, mysql, mysql, mysql query error, mysql query distinct
Sign Up Now!
Solution Provided By: JesterToo
Participating Experts: 1
Solution Grade: A
 
 
 
Loading Advertisement...
20081112-EE-VQP-42 / EE_QW_2_20070628