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

Problem in Serach query

Hi,
my sql query does not work
Expand|Select|Wrap|Line Numbers
  1. SELECT * FROM representative where PinCode_Covered=110065
  2.  
In PinCode_Covered column i have more than one values like
110065, 110061, 110033
and in other rows i have
110065


But it fetch only one record where 110065 exist; why other value not come in search. Any one plz help me out.
Sep 18 '07 #1
15 1498
ajos
283 100+
Hi,
my sql query does not work

SELECT * FROM representative where PinCode_Covered=110065

In PinCode_Covered column i have more than one values like
110065, 110061, 110033
and in other rows i have
110065


But it fetch only one record where 110065 exist; why other value not come in search. Any one plz help me out.
hi,
im not sure wat u mean exactly.....
r u trying to say that the result that is displayed is only for 110065
and not the rest of the values???
regards,
ajos
Sep 18 '07 #2
hi,
im not sure wat u mean exactly.....
r u trying to say that the result that is displayed is only for 110065
and not the rest of the values???
regards,
ajos
hi ajos,

yes!
I want all the rows where PinCode_covered = 110065
Sep 18 '07 #3
ajos
283 100+
hi ajos,

yes!
I want all the rows where PinCode_covered = 110065
firstly check how many rows are there with the above pincode u mentioned....im not exactly sure abt this....check ur query
Sep 18 '07 #4
r035198x
13,262 8TB
Hi,
my sql query does not work

SELECT * FROM representative where PinCode_Covered=110065

In PinCode_Covered column i have more than one values like
110065, 110061, 110033
and in other rows i have
110065


But it fetch only one record where 110065 exist; why other value not come in search. Any one plz help me out.
You have filtered your results by your where clause. Perhaps you should go through a tutorial about what where does.

Edit: Are you sure the other tables have the same value? Perhaps there are some leading or trailing spaces. What type is the PinCode_Covered column?
Sep 18 '07 #5
You have filtered your results by your where clause. Perhaps you should go through a tutorial about what where does.

Edit: Are you sure the other tables have the same value? Perhaps there are some leading or trailing spaces. What type is the PinCode_Covered column?

I don't have too much time to search in toturial. There is no spaces. i have taken varchar datatype for PinCode_Covered column.
Sep 18 '07 #6
r035198x
13,262 8TB
I don't have too much time to search in toturial. There is no spaces. i have taken varchar datatype for PinCode_Covered column.
How do you know that there are no spaces, did you try the query using the TRIM function?
Sep 18 '07 #7
How do you know that there are no spaces, did you try the query using the TRIM function?

I have not checked by TRIM function but i am describing how i stored values

----------------------------
PinCode_Covered
--------------------------
201001
-------------------------
110065, 110061, 110066
-------------------------
110065
-------------------------
110065, 110033, 110001
-------------------------

It is showing only 110065 but it has to display other column also where PinCode is 110065.

Now i think u can understand my problem better.
Sep 18 '07 #8
r035198x
13,262 8TB
I have not checked by TRIM function but i am describing how i stored values

----------------------------
PinCode_Covered
--------------------------
201001
-------------------------
110065, 110061, 110066
-------------------------
110065
-------------------------
110065, 110033, 110001
-------------------------

It is showing only 110065 but it has to display other column also where PinCode is 110065.

Now i think u can understand my problem better.
So you have multiple values?
Use like with %
as in
Expand|Select|Wrap|Line Numbers
  1. where  PinCode_Covered like '%110065%'
Sep 18 '07 #9
So you have multiple values?
Use like with %
as in
Expand|Select|Wrap|Line Numbers
  1. where  PinCode_Covered like '%110065%'
Thanks buddy
It works, but when i attach the query in my php application it displays the single one again.
Sep 18 '07 #10
r035198x
13,262 8TB
Thanks buddy
It works, but when i attach the query in my php application it displays the single one again.
Post the code that you have changed for it.
Also make sure you saved the changes.
Sep 18 '07 #11
Post the code that you have changed for it.
Also make sure you saved the changes.
------
The code in which i used the query as follows
-----
Expand|Select|Wrap|Line Numbers
  1. <?
  2. $Pin_Code = '110065';
  3. $result=mysql_query("SELECT * FROM tablename where PinCode_Covered LIKE '$Pin_Code'");
  4. $num=mysql_num_rows($result);
  5.  
  6. while($row = mysql_fetch_array($resultbb, MYSQL_ASSOC))
  7. {
  8. $PinCode_Covered=$row['PinCode_Covered'];
  9. echo "{$row['PinCode_Covered']}"; } ?>
Sep 18 '07 #12
------
The code in which i used the query as follows
-----
<?
$Pin_Code = '110065';
$result=mysql_query("SELECT * FROM tablename where PinCode_Covered LIKE '$Pin_Code'");
$num=mysql_num_rows($result);

while($row = mysql_fetch_array($resultbb, MYSQL_ASSOC))
{
$PinCode_Covered=$row['PinCode_Covered'];
echo "{$row['PinCode_Covered']}"; } ?>
hey can u tell me why its happening and how to solve this problem?
Sep 18 '07 #13
r035198x
13,262 8TB
------
The code in which i used the query as follows
-----
<?
$Pin_Code = '110065';
$result=mysql_query("SELECT * FROM tablename where PinCode_Covered LIKE '$Pin_Code'");
$num=mysql_num_rows($result);

while($row = mysql_fetch_array($resultbb, MYSQL_ASSOC))
{
$PinCode_Covered=$row['PinCode_Covered'];
echo "{$row['PinCode_Covered']}"; } ?>
You forgot the two % signs.
Sep 18 '07 #14
amitpatel66
2,367 Expert 2GB
------
The code in which i used the query as follows
-----
<?
$Pin_Code = '110065';
$result=mysql_query("SELECT * FROM tablename where PinCode_Covered LIKE '$Pin_Code'");
$num=mysql_num_rows($result);

while($row = mysql_fetch_array($resultbb, MYSQL_ASSOC))
{
$PinCode_Covered=$row['PinCode_Covered'];
echo "{$row['PinCode_Covered']}"; } ?>
You have not given '%' for the variable $Pin_Code

Try the below code:
Expand|Select|Wrap|Line Numbers
  1. <?
  2. $Pin_Code = '%110065%';
  3. $result=mysql_query("SELECT * FROM tablename where PinCode_Covered LIKE '$Pin_Code'");
  4. $num=mysql_num_rows($result);
  5.  
  6. while($row = mysql_fetch_array($resultbb, MYSQL_ASSOC))
  7. {
  8. $PinCode_Covered=$row['PinCode_Covered'];
  9. echo "{$row['PinCode_Covered']}"; } ?>
Sep 18 '07 #15
pbmods
5,821 Expert 4TB
Amit and Praveen:
Please use CODE tags when posting source code:

[CODE=php]
PHP code goes here.
[/CODE]

Amit, this is *not* the first time you've been asked. Don't make me issue a formal warning.
Sep 18 '07 #16

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

Similar topics

6
by: lenny | last post by:
Hi, I've been trying to use a Sub or Function in VBA to connect to a database, make a query and return the recordset that results from the query. The connection to the database and the query...
3
by: Andy_Khosravi | last post by:
I have been trying to build a user friendly search engine for a small database I have created. I'm having some particular problems with one of my date fields. Here's the setup: I'm using...
4
by: Carramba | last post by:
hi! Iam trying to make program were I enter string and serach char. and funktion prints out witch position char is found this is done if funktion serach_char. so far all good what I want do...
3
by: Carramba | last post by:
hi! the code is cinpiling with gcc -ansi -pedantic. so Iam back to my question Iam trying to make program were I enter string and serach char. and funktion prints out witch position char is...
4
by: Dinesh Jain | last post by:
Hi all, I am dealing with a serious problem with an application which displays texts of all the labels perfectly under the setting 96 DPI (from control panel) but doesn't displays labels...
20
by: Development - multi.art.studio | last post by:
Hello everyone, i just upgraded my old postgres-database from version 7.1 to 7.4.2. i dumped out my 7.1 database (with pg_dump from 7.1) as an sql-file with copy-commands and to one file using...
9
by: HC | last post by:
Hello, all, I started out thinking my problems were elsewhere but as I have worked through this I have isolated my problem, currently, as a difference between MSDE and SQL Express 2005 (I'll just...
2
by: raknin | last post by:
Hi, Is there any way using mysql to serach a values in a string where I don't care what is in between, for example: I have a row which contains the following string in the foloowing format ...
1
by: lakshmiRam | last post by:
hi i have a bluetooth dongle and a program to serach all the devices using bluetooth, but the problem is findFirstDevice() function always returns null so it fails in searching but, i know that...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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...

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.