Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 pulling all similar entries

Author  Topic 

marvinv
Starting Member

2 Posts

Posted - 2010-02-01 : 08:58:13
i have a system run by php/mysql. in my system i have a search function. my database has a name field and in it, all the names of the reservations are stored. what i want to do is pull and display all rows that has for example i searched 'XX' name. i want to display all the rows with 'XX' in the name field in my table. how can i achieve this?

example:
TABLE:
|ID|NAME|
| 1| XX|
| 2| XX|
| 3| AB|
when i search XX, i want to display:
ID 1 Name XX
ID 2 Name XX

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2010-02-01 : 09:00:40
[code]select columns..
from yourtable
where Name = @Searchterm
[/code]
Go to Top of Page

bklr
Master Smack Fu Yak Hacker

1693 Posts

Posted - 2010-02-01 : 09:01:32
declare @search varchar(32)

select @search = 'xx'

select * from tablename where name = @search
Go to Top of Page

marvinv
Starting Member

2 Posts

Posted - 2010-02-01 : 09:07:39
i could return how many has the same entry as the one i entered from my search but the problem is i dont know how to display them. btw what does @ in your @Searchterm do? im sorry im just new in mysql thanks guys
Go to Top of Page

webfred
Master Smack Fu Yak Hacker

8781 Posts

Posted - 2010-02-01 : 09:15:06
From MySql comes back a recordset.
To display the data then it is to do via PHP.

But this is not a MySQL or PHP forum.



No, you're never too old to Yak'n'Roll if you're too young to die.
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2010-02-01 : 09:20:03
quote:
Originally posted by marvinv

i could return how many has the same entry as the one i entered from my search but the problem is i dont know how to display them. btw what does @ in your @Searchterm do? im sorry im just new in mysql thanks guys


if you're using mysql please try your luck at some mysql forums. this is ms sql server forum so solns given here are guaranteed to work only in sql server
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2010-02-01 : 09:38:19
select count(*) from yourtable
where Name = 'xx'



Madhivanan

Failing to plan is Planning to fail
Go to Top of Page
   

- Advertisement -