Click here to Skip to main content
15,922,894 members
Please Sign up or sign in to vote.
1.67/5 (2 votes)
See more:
37 Futuresoft Baterry,HDD, Active 5/2/2014 9945678958 fsoft@gmail.com Okhla Okhla phase 111
38 Future India HDD,joystick,Laptop Screen, Active 4/28/2014 9971269129 fIndia@gmail.com Noida Noida
39 Tech_M Baterry,Laptop Screen,Mouse, Active 4/29/2014 9945678955 TechM@gmail.com Noida Noida
46 dgd Baterry,HDD,joystick, Active 5/3/2014 9945678958 fIndia@gmail.com
NULL NULL NULL NULL NULL NULL NULL NULL NULL
I have a database as above. here the Products are separated by comma. I have an product name in session. how will i check whether my session value is present in the product lists or not. please help.
Posted
Comments
[no name] 21-Jun-14 9:02am    
Fire your DBA, after that you can write a query using LIKE to do a wildcard search for the product.
Sergey Alexandrovich Kryukov 21-Jun-14 21:57pm    
Best answer so far. :-)
—SA
ZurdoDev 21-Jun-14 9:04am    
Where are you stuck?

1 solution

Basically, don't.
It's a very bad design idea - you should be using separate tables: one for the rows you have (less the comma separates column), one for the comma separated items (one per row with an ID), and a third to link them together:
37	Futuresoft	Active	5/2/2014	9945678958	fsoft@gmail.com	Okhla	Okhla phase 111
38	Future India	Active	4/28/2014	9971269129	fIndia@gmail.com	Noida	Noida
39	Tech_M	Active	4/29/2014	9945678955	TechM@gmail.com	Noida	Noida
46	dgd	Active	5/3/2014	9945678958	fIndia@gmail.com	
NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL

1       Baterry
2       HDD
3       joystick
4       Laptop Screen
5       Mouse

37      1
37      2
38      2
38      3
38      4
...
You can then add, delete, or check vlues very simply.
SQL is not good at string manipulation, and a database design like yours gives enormous problems and wastes a lot of time and resources.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900