Go Back   TechArena Community > Software > Software Development
Become a Member!
Forgot your username/password?
Tags Active Topics RSS Search Mark Forums Read

Reply
 
Thread Tools Search this Thread
  #1  
Old 18-12-2008
Member
 
Join Date: Feb 2008
Posts: 324
Problem of SQL query

I made some SQL tables and when I run a request query I get duplicated lines. Whereas if I run a request query with the same conditions but I type in only 1 table, the data are correct and are not duplicated.

Can you explain why?
Reply With Quote
  #2  
Old 18-12-2008
Member
 
Join Date: Feb 2008
Posts: 194
Re: Problem of SQL query

If you have a 1-N relationship between table1 and table2 and you do:

Code:
select * from table1 left join table2 on table1.id=table2.id_table1
You will have N resulting lines for each record in your table1
Reply With Quote
  #3  
Old 18-12-2008
Member
 
Join Date: Feb 2008
Posts: 324
Re: Problem of SQL query

Yeah that's true but how to solve the problem?
Reply With Quote
  #4  
Old 18-12-2008
Member
 
Join Date: Feb 2008
Posts: 194
Re: Problem of SQL query

Could you give your request query so that I would see it and help you accordingly.
Reply With Quote
  #5  
Old 18-12-2008
Member
 
Join Date: Feb 2008
Posts: 324
Re: Problem of SQL query

Code:
SELECT 
tic.ticket_id, tic.ticket_label, tic.ticket_detail, 
tic.ticket_date_o, tic.ticket_date_f, tic.ticket_priority, tic.ticket_destination, 
tic.ticket_close, si.servInfo_label, app.app_name 

FROM 
ticket tic, applicant app, service_info si

WHERE 
app.app_num = tic.ticket_applicant_num 
AND 
tic.ticket_servInfo_num = si.servInfo_num 
AND 
tic.ticket_label like 'password%%' OR tic.ticket_detail like 'password%%' 

ORDER BY tic.ticket_id desc;
Reply With Quote
  #6  
Old 18-12-2008
Member
 
Join Date: Feb 2008
Posts: 194
Re: Problem of SQL query

An example of incorrect query!

Basically, if your applicants are double in the database you will get duplicated results. That describes the problem effectively.
Reply With Quote
Reply

  TechArena Community > Software > Software Development
Tags: ,



Thread Tools Search this Thread
Search this Thread:

Advanced Search


Similar Threads for: "Problem of SQL query"
Thread Thread Starter Forum Replies Last Post
Query cache denied problem Alibamu Software Development 6 19-06-2010 12:35 AM
Problem of nested query MAGAR Software Development 4 09-12-2009 09:55 PM
Coldfusion query problem AZUL Software Development 3 26-11-2009 07:55 PM
Problem with construction of a query KAILEY Software Development 3 01-10-2009 10:58 PM
Turn on MySQL query cache to speed up query performance DMA2Superman Software Development 3 07-07-2009 10:26 AM


All times are GMT +5.5. The time now is 11:24 PM.