Need help in mysql query..

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • dotnetduke
    New Member
    • Aug 2010
    • 2

    #1

    Need help in mysql query..

    I am using a query to search a ticket no with eigther tickettype is like "EMER" or "Short Notice", but iam getting multiple values. Its not searching with the ticket no. Please let me know what the issue is in my query. Below is the query


    Code:
    SELECT T.Ticketsid, T.TicketType, T.TicketNo 
    FROM Tickets T INNER JOIN TicketCustomers TC ON TC.TicketsId= T.TicketsId LEFT JOIN correspondence C ON C.Ticketsid = T.Ticketsid 
    WHERE   T.TicketNo='102081837' AND T.TicketType LIKE '%EMER%' OR T.TicketType = 'SHORT NOTICE'
    GROUP BY TC.TicketCustomersId ORDER BY T.Ticket_Rec_Date DESC
    I am getting the below result with different ticketnos, ia m expecting only the ticketno in the where condition.

    Code:
    Ticketsid TicketType    TicketNo
    4661      SHORT NOTICE  102180761
    4659      SHORT NOTICE  102180758
    4657      SHORT NOTICE  102180751
    3998      SHORT NOTICE  102161521
    2944      SHORT NOTICE  102141331
    1292      SHORT NOTICE  102081837
    Last edited by Atli; Aug 7 '10, 02:41 AM. Reason: Please use [code] tags when posting code or preformatted text.
  • yarbrough40
    Contributor
    • Jun 2009
    • 320

    #2
    Your problem is in your WHERE clause. you are missing perentheses.

    try this:
    Code:
    WHERE T.TicketNo='102081837' AND (T.TicketType LIKE '%EMER%' OR T.TicketType = 'SHORT NOTICE')
    it is important that you understand why. If you don't please ask and we can explain. Enjoy!

    Comment

    • dotnetduke
      New Member
      • Aug 2010
      • 2

      #3
      Thanks a lot for the reply. I have figured it out.

      Comment

      Working...