query with 2 criterias
helo all,
i have a date field in a table, the date is stored as 2005-12-04 in the database.i want to filter the data on year basis, such as the datalist wil display all files in 2005 when 2005 is selected in the combo dropdown box.
How should i combine both of the querys as one to get the right data in my datlist:
test = "Select * from proposals where date = " & Combo2.Text
strQuery = "Select filename from proposals where bedrijf_ID = " & DataList1.BoundText
Hope you understand what my question is. The query need to meet 2 criteria, one the year in the date field should be equal to the year in the combobox and the bedrijf_id should be equal to datalist1.bound text. And the result shoulbe filename wich is displyaed in the datalist.
thanks in advance
[808 byte] By [
randjana] at [2007-11-11 8:37:41]

# 1 Re: query with 2 criterias
What kind of database is it (e.g., Access, SQL Server, etc.)?
# 2 Re: query with 2 criterias
Oh sorry i didn't mentioned it, the database is mysql and i'am programming in vb6.0
# 3 Re: query with 2 criterias
You should be using DATE or DATETIME columns to store dates (see http://dev.mysql.com/doc/refman/5.0/en/date-and-time-types.html for more information). Then your query should look like this:
SELECT * FROM proposals
WHERE date BETWEEN '2005-01-01' AND '2005-12-31'
AND bedrijf_ID = 1
# 4 Re: query with 2 criterias
Phil i get mysql syntax error with the following
Case 0
test = "Select filename from proposals where bedrijf_ID = " & DataList1.BoundText
strQuery = test & "Select filename from proposals where datum BETWEEN '2005-01-01' AND '2005-12-31' "
Adoproposal.RecordSource = strQuery
Adoproposal.Refresh
End Select
DataList2.ReFill
DataList2.Refresh
End Sub
what is the correct syntax?