473,803 Members | 4,458 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

select problem

pradeepjain
563 Contributor
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 1906
ssnaik84
149 New Member
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 Recognized Expert Expert
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
2453
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
2895
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 try create a param using this search critieria it can never seem to locate what I am looking for. For example, check out the following XML file: ------------------------- <data> <aBlock id="1"> <tmpdata> <stringType>Hi</stringType>
3
1590
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 with and without the <FORM></FORM>. In Mac Netscape 6 the onChange does not activate if there is no <FORM></FORM>. When I put it in a form as indicated below the value of train.options.value is undefined. What am I doing wrong?
3
6474
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 COULD be wrong... :) I've tried the access group...twice...and all I get is "Access doesn't like ".", which I know, or that my query names are too long, as there's a limit to the length of the SQL statement(s). But this works when I don't try to...
1
4180
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 couple of tables in my database using INNER JOINS and the WHERE clause to specify the required constraints. However, I also want to read two fields from a *single* record from a table called 'Locations' and then apply one of these field's values...
2
9929
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 (multi-select without modifier keys). I got that working fine, but I also wanted to keep rows selected after a sort, which I do by storing the row's id in an arraylist. The idea was to do the sort and then go back and re-select the rows with that...
2
3664
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 /////////////////////////////////////////////////////////////////////////////////////// <form action="whatever.php" method="post"> <select name="zip_code" onchange="makeRequest('getCity.php?state='+this.form.zip_code.options.value)" multiple="multiple" size="20">
3
12559
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 = window.document.forms.srcList;
13
5802
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 CatalogImage where imgID also needs to be placed. Below is my code behind to carry the catID using the Select @@Identity and insert imgID to the bridge table. No data is being entered into the bridge table.
2
4365
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 of the xml: <Stats> <Structure> <Column DisplayName="GP" FieldName="GamesPlayed" Priority="1" /> <Column DisplayName="G" FieldName="Goals" Priority="2" />
0
9564
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10316
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
10069
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9125
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7604
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6842
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5500
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5629
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3798
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.