I am struggling to get the proper syntax for a SQL query. I have looked through all I can but cant seem to get anything that works.
I want to check to see if a record is in the database e.g.
SELECT Date,Time FROM loadings WHERE Date='21-06-2011' AND Time ='7'
If it does then I can update it, if it doesnt I need to add it first before I can cary out some operations.
I tried
[php]
IF EXISTS(SELECT Date,Time FROM loadings WHERE Date='21-06-2011' AND Time ='7')
{
// Record exists do nothing
}
else
{
// Insert record
INSERT Date,Time INTO loadings VALUES Date='21-06-2011' AND Time ='7'
}
[/php]
Can anyone guide me on the correct syntax to use.
By the way just founf this site and reading through seems excellent. Particularly the suggestions given from previos submissions to answer the question. I look through all them but didn't find my answer.
Regards Trevor