473,387 Members | 1,791 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,387 software developers and data experts.

select problem

pradeepjain
563 512MB
I have a table like this

Expand|Select|Wrap|Line Numbers
  1. +---------------------------+--------------------------+------+-----+---------+----------------+
  2. | Field                     | Type                     | Null | Key | Default | Extra          |
  3. +---------------------------+--------------------------+------+-----+---------+----------------+
  4. | patient_id                | int(5) unsigned zerofill | NO   | PRI | NULL    | auto_increment | 
  5. | Surname                   | varchar(100)             | YES  |     | NULL    |                | 
  6. | Firstname                 | varchar(100)             | YES  |     | NULL    |                | 
  7. | Gender                    | enum('Male','Female')    | YES  |     | NULL    |                | 
  8. | Dob                       | date                     | YES  |     | NULL    |                | 
  9. | Age                       | int(3)                   | YES  |     | NULL    |                | 
  10. | Address                   | text                     | YES  |     | NULL    |                | 
  11. | City                      | varchar(100)             | YES  |     | NULL    |                | 
  12. | State                     | varchar(100)             | YES  |     | NULL    |                | 
  13. | Pincode                   | int(10)                  | YES  |     | NULL    |                | 
  14. | Address_landmark          | varchar(100)             | YES  |     | NULL    |                | 
  15. | Landline                  | varchar(20)              | YES  |     | NULL    |                | 
  16. | Mobile                    | varchar(20)              | YES  |     | NULL    |                | 
  17. | Email                     | varchar(30)              | YES  |     | NULL    |                | 
  18. | Smoker                    | enum('Yes','No')         | YES  |     | NULL    |                | 
  19. | Alchohol                  | enum('Yes','No')         | YES  |     | NULL    |                | 
  20. | Discover_diabetic         | text                     | YES  |     | NULL    |                | 
  21. | Emergency_contact_name    | varchar(100)             | YES  |     | NULL    |                | 
  22. | Emergency_telephone       | varchar(20)              | YES  |     | NULL    |                | 
  23. | Physician_id              | int(10) unsigned         | NO   | MUL | NULL    |                | 
  24. | Physician_name            | varchar(100)             | YES  |     | NULL    |                | 
  25. | Physician_phone           | varchar(20)              | YES  |     | NULL    |                | 
  26. | Physician_Mobile          | varchar(20)              | YES  |     | NULL    |                | 
  27. | Physician_after_office    | varchar(20)              | YES  |     | NULL    |                | 
  28. | consultation              | enum('Yes','No')         | YES  |     | NULL    |                | 
  29. | Diabetologist_name        | varchar(100)             | YES  |     | NULL    |                | 
  30. | Diabetologist_number      | varchar(20)              | YES  |     | NULL    |                | 
  31. | Chiropodist_name          | varchar(100)             | YES  |     | NULL    |                | 
  32. | Chiropodist_number        | varchar(20)              | YES  |     | NULL    |                | 
  33. | Hospital_name             | varchar(100)             | YES  |     | NULL    |                | 
  34. | Hospital_number           | varchar(20)              | YES  |     | NULL    |                | 
  35. | Diabetes_nurse_name       | varchar(100)             | YES  |     | NULL    |                | 
  36. | Diabetes_nurse_number     | varchar(20)              | YES  |     | NULL    |                | 
  37. | Type_of_diabetes          | varchar(100)             | YES  |     | NULL    |                | 
  38. | Date_of_diagnosis         | date                     | YES  |     | NULL    |                | 
  39. | Symptoms_at_diagnosis     | text                     | YES  |     | NULL    |                | 
  40. | Weight_at_diagnosis       | int(3)                   | YES  |     | NULL    |                | 
  41. | Past_family_history       | text                     | YES  |     | NULL    |                | 
  42. | Past_medical_history      | text                     | YES  |     | NULL    |                | 
  43. | Allergies                 | text                     | YES  |     | NULL    |                | 
  44. | Doctors_observation       | text                     | YES  |     | NULL    |                | 
  45. | Alternate_medicine        | enum('Yes','No')         | YES  |     | NULL    |                | 
  46. | Alternate_medicine_reason | text                     | YES  |     | NULL    |                | 
  47. | addedon                   | varchar(50)              | NO   |     | NULL    |                | 
  48. | addedip                   | varchar(50)              | NO   |     | NULL    |                | 
  49. | addedby                   | varchar(100)             | NO   |     | NULL    |                | 
  50. | updatedon                 | varchar(50)              | NO   |     | NULL    |                | 
  51. | updatedip                 | varchar(50)              | NO   |     | NULL    |                | 
  52. | updatedby                 | varchar(100)             | NO   |     | NULL    |                | 
  53. | userdetails               | text                     | YES  |     | NULL    |                | 
  54. +---------------------------+--------------------------+------+-----+---------+----------------+
  55.  
and i have values in table like
Expand|Select|Wrap|Line Numbers
  1.  select * from viioforms_form1;
  2. +------------+---------+-----------+--------+------------+------+-----------------------------+-------------+-------------+---------+------------------+------------+--------------+--------------------------+--------+----------+-------------------+------------------------+---------------------+--------------+----------------+-----------------+------------------+------------------------+--------------+--------------------+----------------------+------------------+--------------------+---------------+-----------------+---------------------+-----------------------+------------------+-------------------+-----------------------+---------------------+---------------------+----------------------+-----------+---------------------+--------------------+---------------------------+--------------+-----------------+---------+-----------+-----------+-----------+-------------------------------------------------------------------------------------------------------------------+
  3. | patient_id | Surname | Firstname | Gender | Dob        | Age  | Address                     | City        | State       | Pincode | Address_landmark | Landline   | Mobile       | Email                    | Smoker | Alchohol | Discover_diabetic | Emergency_contact_name | Emergency_telephone | Physician_id | Physician_name | Physician_phone | Physician_Mobile | Physician_after_office | consultation | Diabetologist_name | Diabetologist_number | Chiropodist_name | Chiropodist_number | Hospital_name | Hospital_number | Diabetes_nurse_name | Diabetes_nurse_number | Type_of_diabetes | Date_of_diagnosis | Symptoms_at_diagnosis | Weight_at_diagnosis | Past_family_history | Past_medical_history | Allergies | Doctors_observation | Alternate_medicine | Alternate_medicine_reason | addedon      | addedip         | addedby | updatedon | updatedip | updatedby | userdetails                                                                                                       |
  4. +------------+---------+-----------+--------+------------+------+-----------------------------+-------------+-------------+---------+------------------+------------+--------------+--------------------------+--------+----------+-------------------+------------------------+---------------------+--------------+----------------+-----------------+------------------+------------------------+--------------+--------------------+----------------------+------------------+--------------------+---------------+-----------------+---------------------+-----------------------+------------------+-------------------+-----------------------+---------------------+---------------------+----------------------+-----------+---------------------+--------------------+---------------------------+--------------+-----------------+---------+-----------+-----------+-----------+-------------------------------------------------------------------------------------------------------------------+
  5. |      00001 |  m      |  pradeep  |        | 1984-08-19 |   25 |  #287,2nd block,2nd cross,  |  bangalore  |  karnataka  |  560085 |  pillar          |  26792042  |  9980572765  |  gpradeepjain@gmail.com  |        |          |  yesterday        |  pradeep               |  26792042           |            1 |  ashok         |  26792042       |  9980572765      |  9980572765            |              |  naveen1           |  9980572761          |  naveen2         |  9980572762        |  naveen3      |  9980572763     |  naveen4            |  9980572764           |  not known       | 2009-09-09        |  unknown              |                  78 |  none               |  none1               |  nope     |  not yet done       |                    |  no reason                |  1258714681  |  192.168.2.112  |  admin  |           |           |           |  Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.3) Gecko/20090909 Fedora/3.5.3-1.fc11 Firefox/3.5.3 FirePHP/0.3 | 
  6. |      00002 |  m      |  pradeep  |        | 1984-08-19 |   25 |  #287,2nd block,2nd cross,  |  bangalore  |  karnataka  |  560085 |  pillar          |  26792042  |  9980572765  |  gpradeepjain@gmail.com  |        |          |  yesterday        |  pradeep               |  26792042           |            1 |  ashok         |  26792042       |  9980572765      |  9980572765            |              |  naveen1           |  9980572761          |  naveen2         |  9980572762        |  naveen3      |  9980572763     |  naveen4            |  9980572764           |  not known       | 2009-09-09        |  unknown              |                  78 |  none               |  none1               |  nope     |  not yet done       |                    |  no reason                |  1258714684  |  192.168.2.112  |  admin  |           |           |           |  Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.3) Gecko/20090909 Fedora/3.5.3-1.fc11 Firefox/3.5.3 FirePHP/0.3 | 
  7. |      00003 |  m      |  pradeep  |        | 1984-08-19 |   25 |  #287,2nd block,2nd cross,  |  bangalore  |  karnataka  |  560085 |  pillar          |  26792042  |  9980572765  |  gpradeepjain@gmail.com  |        |          |  yesterday        |  pradeep               |  26792042           |            1 |  ashok         |  26792042       |  9980572765      |  9980572765            |              |  naveen1           |  9980572761          |  naveen2         |  9980572762        |  naveen3      |  9980572763     |  naveen4            |  9980572764           |  not known       | 2009-09-09        |  unknown              |                  78 |  none               |  none1               |  nope     |  not yet done       |                    |  no reason                |  1258715003  |  192.168.2.112  |  admin  |           |           |           |  Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.3) Gecko/20090909 Fedora/3.5.3-1.fc11 Firefox/3.5.3 FirePHP/0.3 | 
  8. +------------+---------+-----------+--------+------------+------+-----------------------------+-------------+-------------+---------+------------------+------------+--------------+--------------------------+--------+----------+-------------------+------------------------+---------------------+--------------+----------------+-----------------+------------------+------------------------+--------------+--------------------+----------------------+------------------+--------------------+---------------+-----------------+---------------------+-----------------------+------------------+-------------------+-----------------------+---------------------+---------------------+----------------------+-----------+---------------------+--------------------+---------------------------+--------------+-----------------+---------+-----------+-----------+-----------+-------------------------------------------------------------------------------------------------------------------+
  9. 3 rows in set (0.00 sec)


but when i give query like
Expand|Select|Wrap|Line Numbers
  1. select * from viioforms_form1 where Surname='m' and Firstname='pradeep';
  2. Empty set (0.00 sec)
  3.  
it should give th result . but its not ....i am not knowing the reason.
Nov 20 '09 #1
2 1883
ssnaik84
149 100+
while inserting values to table, have u checked for extra spaces?
e.g. 'm' might be entered as 'm '
try using 'like' keyword
Nov 20 '09 #2
Atli
5,058 Expert 4TB
Hey.

Yea, I think ssnaik is right there. From what you posted, it looks like there are extra spaces before the values in both Surname and Firstname.

You can try the TRIM function.
Expand|Select|Wrap|Line Numbers
  1. SELECT stuff FROM tpl WHERE TRIM(Surname) = 'm' etc..
Ideally, you should trim stuff before it is inserted into the table, to prevent problems like these.
Nov 20 '09 #3

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

Similar topics

1
by: D. Shifflett | last post by:
Hi all, I am having trouble with a program that ran fine on Python 2.0 (#0, Mar 1 2001, 01:47:55) on linux2 but will not work on Python 2.3.2 (#1, Oct 8 2003, 17:33:47) on linux2
2
by: RanDeep | last post by:
I have two nodes that both exist underneath the root node. They are linked, however, in the sense that one of the nodes contains a copy of an id that is used to refer to the other. However, when I...
3
by: Dennis M. Marks | last post by:
I have a problem with the following code. It generates a <FORM><SELECT><OPTION> list. There is no problem in the generating. The problem is in the execution as follows. It works fine in Mac IE...
3
by: Tcs | last post by:
My backend is DB2 on our AS/400. While I do HAVE DB2 PE for my PC, I haven't loaded it yet. I'm still using MS Access. And no, I don't believe this is an Access question. (But who knows? I...
1
by: Andrew McNab | last post by:
Hi folks, I have a problem with an MS Access SQL query which is being used in an Access Report, and am wondering if anyone can help. Basically, my query (shown below) gets some records from a...
2
by: Chris Plowman | last post by:
Hi all, I was wondering if anyone can help me with a really annoying problem I have been having. I made a derived datagrid class that will select the row when a user clicks anywhere on a cell...
2
by: areef.islam | last post by:
Hi, I am kinda new to javascript and I am having this problem with selecting multiple options from a select tag. Hope someone can help me out here. here is my code...
3
by: imrantbd | last post by:
This is my first problem.Please help me. I have the following code: <head> <script language="JavaScript"> function addSrcToDestList() { destList1 = window.document.forms.destList; srcList...
13
by: PinkBishop | last post by:
I am using VS 2005 with a formview control trying to insert a record to my access db. The data is submitted to the main table no problem, but I need to carry the catID to the bridge table...
2
by: djnokturnal | last post by:
Hey guys / gals, First time posting and of course I am sure it is something that has been answered 100 times but for some reason I just cant find the answer :) First off here is the structure...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

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.