Results 1 to 6 of 6

Thread: Problem of SQL query

  1. #1
    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?

  2. #2
    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

  3. #3
    Join Date
    Feb 2008
    Posts
    324

    Re: Problem of SQL query

    Yeah that's true but how to solve the problem?

  4. #4
    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.

  5. #5
    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;

  6. #6
    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.

Similar Threads

  1. Query cache denied problem
    By Alibamu in forum Software Development
    Replies: 6
    Last Post: 19-06-2010, 12:35 AM
  2. Problem of nested query
    By MAGAR in forum Software Development
    Replies: 4
    Last Post: 09-12-2009, 09:55 PM
  3. Coldfusion query problem
    By AZUL in forum Software Development
    Replies: 3
    Last Post: 26-11-2009, 07:55 PM
  4. Problem with construction of a query
    By KAILEY in forum Software Development
    Replies: 3
    Last Post: 01-10-2009, 10:58 PM
  5. Turn on MySQL query cache to speed up query performance
    By DMA2Superman in forum Software Development
    Replies: 3
    Last Post: 07-07-2009, 10:26 AM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,714,055,035.05484 seconds with 16 queries