I have an SQL database which I need to create a procedure or query that is linked to a web front end where the user can type in a value which will be in one of the columns of the database. The user types in the value, submits the command (just normal text entry in a textbox in the website), a query is ran in the background to view all persons who have this value in the column under their entry.
User entry to determine the outcome for a view of specific people.
SQL Side I have currently but not certain it is correct, works but not as intended!
I have a table with people in it and a model of interest value column.
Each model of interest is just a number 1-7 which relates to a product range in another table. So 1 = a Corsa, 2 = Astra, 3 = Vectra etc.
So in the persons table, they will have purely a 1 or a 2 etc. Now I need it to be linked to the model table so if it sees 1 it looks for Corsa rather than the number 1.
A user types in the frontend, select all users interested in a Corsa, it will look up the word corsa and match it to the value 1, then search for 1 in the model of interest column in the person table.
So far I have the following query. Any suggestions as I’m stumped for today. Will try again tomorrow.
SELECT TOP 100 [ld_idno]
,[ld_company]
,[ld_decisionmaker]
,[ld_decisionmaker_workphone]
,[ld_decisionmaker_mobile]
,[ld_decisionmaker_email]
,[ld_discussion_model]
FROM [FMLive204].[dbo].[tblLeads]
SELECT a.po_word
FROM dbo.tblPopulation a
INNER JOIN dbo.tblLeads b
ON ld_discussion_model = po_idno
WHERE [po_word]='Corsa'
SELECT TOP 100 Unique Records
company name
customer name
customer workphone]
customer mobile]
customer email]
[ld_discussion_model] Model of interest = 1
FROM [FMLive204].[dbo].[tblLeads]
SELECT a.po_word
FROM dbo.tblPopulation a (table a)
INNER JOIN dbo.tblLeads b (table b)
ON ld_discussion_model = po_idno (if the model of interest 1 is the same as an entry in the other table, pick the value in the next columne (po_word)
WHERE [po_word]=’Corsa’
Daniel,
Below I’ve outlined the stored procedure which would require the userdata (e.g. Corsa entered from the website) and return all fields from tblpopulation where ‘po_idno’ is in the list matched against the tblLeads. Not having the tblpopulation definition I’m guessing for field name ‘po_idno’ is the field which has the value 1-7 in it.
Once you create the procedure you’ll have to execute it which more information can be found @ http://msdn.microsoft.com/en-us/library/ms189915.aspx