Click here to Skip to main content
16,004,806 members
Please Sign up or sign in to vote.
3.50/5 (2 votes)
See more:
Now i have Product data that have been add in table

in my table have many column Example id,name,description

my question was here

if first product was out of stock and that have description cough,fever,cold

i want to select another product that have some data in description like first product

example product3 have description fever,Sneeze,etc..

how to create sql statement to select product3 that have some text like my first product in description column

thank you so much for answer and so sorry for my english, i'm not good in english but i've try to practice
Posted
Updated 16-Feb-12 7:34am
v2
Comments
RDBurmon 16-Feb-12 13:55pm    
To expect answer from us you have to share some more details .
1) We need table structure of product table.
2) We need table structure of that table where you are storing "out of stock" data.
3) We need some data from product table (may be result of "SELECT * FROM Product")
4) We need some data from "out of stock" table (may be result of "SELECT * FROM out_of_stock")
pongpanut 16-Feb-12 14:33pm    
structer of producttable is "ID,NAME,DESCRIPTION,BARCODE,ID_Unit,ID_Producttype,Quantity"

i haven't table out of stock

when i've add product to database i'll add quantity to table too

when i've sell a product. Quantity will have minus too

if quantity = 0 when i've select product i want to search name of another product that have some text in description product like first product that i've search

Example i've search for Tylenol500 but Tylenol500 have quantity = 0 i would like to select paracetamol that have quantity = 5
Shahin Khorshidnia 16-Feb-12 14:40pm    
Not a good Idea.
Have a separate ProductDescription table.
ID, Prodcut_ID, Value

Create Table ProductDescription
(
ID Bigint Identity(1,1) NoT Null Primary Key,
Product_ID Not Null References Product(ID),
Value nvarchar(50) Not Null)
pongpanut 16-Feb-12 14:48pm    
that mean i must to fix description for a product by create new table for create description for user choose one description

that Right??
[no name] 16-Feb-12 17:11pm    
you can add a product group column to the table and add all the products with the same description to same group and then query based on that..

1 solution

split the description with delimeter, in this case i think its comma, then make a dynamic query and add the divided description with like operator....this is a bit slow but u'll get the required result.
CTE can also solve ur problem....

for further assistance please share the table structure.

Regards
 
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