warning: Creating default object from empty value in /home/skyontech/www/www/blog/modules/taxonomy/taxonomy.pages.inc on line 34.

Using the SQL MOD function in a select statement

Each photo on my photo-blog is a record in a MySQL database, but not every day of the year has a photo. I’ve been adding photos on and off since August, 2004, and each day I’d like to automatically provide links to the older photos I’ve posted on that day in the past (ie Jan 11 2010, Jan 11 2009, Jan 11 2008 and so on, but ONLY if they exist). I could have my PHP code loop through each of the possible dates and see if there is a record, but I’d rather have a single SQL command that would return just the records I was looking for. Somehow the MOD command seemed like the right place to start, but how?

Escaping wildcard characters % and _ in SQL

It seems like an obvious question, but when someone on an IBM developerWorks forum asked how to use wildcards as literals in SQL I realized I didn't know the answer off hand! How DO you find all the records with a part number that contains an underscore, say? SELECT * FROM partno WHERE part LIKE '%_%' doesn't work as we'd like!

Syndicate content