Page 1 of 1

database_query

Posted: Fri Jun 10, 2005 12:02 pm
by Jr
ok... I have a simple database query that looks for entrys that exactly match a date that is on a calendar. I want to set it up so i can repeat entrys (every year, week, etc.) but i dont know how to query 'part' of an entry in a db. Anyone want to help?

Posted: Fri Jun 10, 2005 1:28 pm
by jammindice
This is what i use to search through email addresses. You ARE using mysql i presume.

select * from mailbox where name like concat('%$search%') order by name

Thanks,
Shaun Mickey
270net Technologies
Systems Administrator

Posted: Fri Jun 10, 2005 4:28 pm
by Jr
ok, now what is the concat() function? how exactly does it work? I tried it and it didn't seem to work how i thought it would. Is there any way I can just do something like this:

Code: Select all

$date = "%-06-23";

$day_query_2	=	mysql_query( "SELECT * FROM calendar WHERE received='$date' LIMIT $limit" );
I basically want the year part of the date to be random but I dont know how to do that.

Posted: Fri Jun 10, 2005 5:02 pm
by Buddha443556
How about the DAY() and MONTH() functions?

Code: Select all

WHERE DAY(received) = 23 AND MONTH(received) = 6

Posted: Fri Jun 10, 2005 5:23 pm
by Jr
hmm... giving me a MySQL error? Did I put it in wrong? I removed the "DAY()" function and it works but doesn't when I remove "MONTH()" function...

Code: Select all

$day_query_2	=	mysql_query( "SELECT * FROM calendar WHERE MONTH(received)='$new_month_num' AND DAY(received)='$new_day' LIMIT $limit" );

Posted: Fri Jun 10, 2005 5:37 pm
by Jr
...figured it out DAYOFMONTH()... Thanks a lot for the help.