On Wednesday 14 September 2005 07:36 pm, Jesús Alain Rodríguez Santos wrote: > I have a table colum in mysql with two fields: day and month. I > would like to know if it's possible to make a query where I can > determine if exist days before to a selected day, for example: > if I have in my table: > day 19 - month 05, I wish to know if there are previous days > inserted at the 19, the days they are not inserted in the table, > they are inserted according your selection, what I want to get is > that every time that you insert a day, I want to check if there > are days previous to the one already inserted in the table in the > same month, in case that there are not them then they owe you > to insert together with the one selected, I haven't tried this, but the logic should work according to the manual: You don't have to check, you can just insert all the data. If the row already exists, the data will not be inserted. This assumes that you have a constraint on the table which prevents duplicate values! $day=19; $month=5; for($i=1;i<=$day;i++){ $result=mysql_query("INSERT INTO table (month,day) VALUES (5,$i)"); } If you don't have a constraint, then you will have to loop over the data for that month and insert the rows where they don't already exist. > I wait they understand me what I want: > I work php/mysql. create table tableA ( day int, month int ); select * from tableA where month=5 and day < 19; This will select everything from the 5th month and before the 19th day of the 5th month. Is that what you were going for? > > sorry for my english i'm cuban > Thank you and excuse the nuisances > > > > -- > Este mensaje ha sido analizado por MailScanner > en busca de virus y otros contenidos peligrosos, > y se considera que está limpio. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php