473,326 Members | 2,438 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,326 software developers and data experts.

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


Expand|Select|Wrap|Line Numbers
  1. SELECT T.Ticketsid, T.TicketType, T.TicketNo 
  2. FROM Tickets T INNER JOIN TicketCustomers TC ON TC.TicketsId= T.TicketsId LEFT JOIN correspondence C ON C.Ticketsid = T.Ticketsid 
  3. WHERE   T.TicketNo='102081837' AND T.TicketType LIKE '%EMER%' OR T.TicketType = 'SHORT NOTICE'
  4. 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.

Expand|Select|Wrap|Line Numbers
  1. Ticketsid TicketType    TicketNo
  2. 4661      SHORT NOTICE  102180761
  3. 4659      SHORT NOTICE  102180758
  4. 4657      SHORT NOTICE  102180751
  5. 3998      SHORT NOTICE  102161521
  6. 2944      SHORT NOTICE  102141331
  7. 1292      SHORT NOTICE  102081837
Aug 6 '10 #1
2 1147
yarbrough40
320 100+
Your problem is in your WHERE clause. you are missing perentheses.

try this:
Expand|Select|Wrap|Line Numbers
  1. 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!
Aug 7 '10 #2
Thanks a lot for the reply. I have figured it out.
Aug 7 '10 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: joemyre | last post by:
Hi everyone, What I'm trying to do is take php variables i got from user input, and pass them as the MySQL query terms. $query = "select * from ident where ".$searchtype1."=".$searchterm1."";...
0
by: Murphy | last post by:
I am currently migrating a db from SQL Server & MySQL and ? (front end yet to be decided upon) As I familiarise myself with MySQL populating tables etc can be quite clumbersome. After reading the...
0
by: taras.di | last post by:
Hi everyone, I've come across an extremely strange problem. The exact same query in both mysql command line client, and mysql query browser gives entirely different results. I was hoping someone...
2
by: Flic | last post by:
Hi, I have a basic db that I access with MySQL query browser. Everything seems fine to me but I am using this db as part of a php shopping basket and when I try to add an item I get: Notice:...
6
by: traineeirishprogrammer | last post by:
I am currently working on a project where I need to sort my MYSQL query results by different categories. How ever the code does not seem to be working properly and I spend too much time on it...
2
by: stmfc | last post by:
i have a problem with user creation for mysql db i think the problem stems from string style. GRANT ALL ON newDB.* TO 'test'@'localhost' IDENTIFIED BY 'test'; i am...
10
by: Lloyd Harold | last post by:
I'm very new to PHP and attempting to put together a simple script for retrieving MySQL data of personal records. The MySQL table I'm using consists of: 0: id 1: name 2: location (an integer...
1
by: pretzelboy | last post by:
Hi, I last wrote software 13years ago in the pascal, dbase, clipper days. I have recently built a Ubuntu Box and with C++ (and help from the web) setup a serial barcode reader program using Mysql...
3
by: emsik1001 | last post by:
Hi http://dev.mysql.com/doc/query-browser/en/mysql-query-browser-connection.html I'm trying to connect from my Windows based PC to a dedicated server which is running on Linux system. I...
5
by: lisles | last post by:
i have a page funtion.php which hs the function to connect to the db /* Mysql Connection */ function connect(){ global $db_server,$db_user,$db_pass,$db;//Global Values from the config.php...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.