i am currently designing a study resource site for a college, as part of this site i have to design a personal calendar for the students to be able to insert diary entries and view them when the time is right.
Here comes my problem.
I need a statement that will check a database table to see whether it has nothing in it. I have a table with 3 fields that contain no data( username, day_id, message. I need my code to check that the teo fields username and day_id have no data in them. I need this so that i can insert data into that record when these two fields are empty and update the fields when there is data in them.
Sorry for the longwinded message but i have been fussing over this all day and it has got more complicated by the hour.Im not sure if this is what you want:
select count(*) from tablename where
username is not null and day_id is not null;|||anyone who writes "An SQL statement!" instead of "A SQL statement!" surely deserves a reply
under which circumstances will you find a row where both username and day_id are empty but message isn't? whose message would it be, and for which day?
perhaps if you would kindly show us the CREATE TABLE statement that you used to create the table?|||anyone who writes "An SQL statement!" instead of "A SQL statement!" surely deserves a reply
under which circumstances will you find a row where both username and day_id are empty but message isn't? whose message would it be, and for which day?
perhaps if you would kindly show us the CREATE TABLE statement that you used to create the table?
Basically, i wasnt searching the message field because the contents of it are irrelivant. I am running a check as to whether a record is in the database for that username and that day. Example username :gr203 example day_id: 1(monday)
The check is necessary as it determines whether i need to run an insert or update statement. I cannot have two entries in the table for the same username and day hence if both are null then the entry does not already exist so insert the data, else there is already data for that entry so update the specified record.
Thankyou both for your replies so far.|||my point is: if the given user has no entry for the given day, there will not be a row with NULL in those two columns, there won't be a row at all!!
see the difference?
Wednesday, March 7, 2012
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment