>Your big mistake was delimiting the identifiers when creating the table. > > "Identifiers" are table names, field names, index names, etc. The > "delimiter" for these is "`" in MySQL. When you use the delimiter around > the identifiers, the database allows you to create nearly any name you > can possibly think of, including "reserved words." Reserved words are, > well words that the system has reserved for its own internal use, so > should not be utilized by users.
This cannot possibly be stated often enough. Kristina > Hi Bev: > > > Creating a field/variable named desc and spending hours trying to figure > > out why MySQL was balking at my query with its typically enigmatic error > > messages. > > Your big mistake was delimiting the identifiers when creating the table. > > "Identifiers" are table names, field names, index names, etc. The > "delimiter" for these is "`" in MySQL. When you use the delimiter around > the identifiers, the database allows you to create nearly any name you > can possibly think of, including "reserved words." Reserved words are, > well words that the system has reserved for its own internal use, so > should not be utilized by users. As you've now discovered, delimiting > identifiers when creating tables is the genesis of a world of pain. > > If you tried to create a table with a name called "desc" in it without > delimiting it, MySQL would have complained to you up front, saving you > the agony. > > > > Or like the time (very recently) when I was converting timestamps to > > calculate the number of days between two given dates. I used the > > number_format() function... > > Uh, just making sure... Did you convert the timestamps via > number_format() then do the math? Ouch. This is the kind of stuff the > date functions, like date_diff(), etc, in MySQL and PHP are for. > Faster, more accurate, easier. Then format the result. > > --Dan > > -- > T H E A N A L Y S I S A N D S O L U T I O N S C O M P A N Y > data intensive web and database programming > http://www.AnalysisAndSolutions.com/ > 4015 7th Ave #4, Brooklyn NY 11232 v: 718-854-0335 f: 718-854-0409 > _______________________________________________ > New York PHP User Group Community Talk Mailing List > http://lists.nyphp.org/mailman/listinfo/talk > > http://www.nyphp.org/show_participation.php > > _______________________________________________ New York PHP User Group Community Talk Mailing List http://lists.nyphp.org/mailman/listinfo/talk http://www.nyphp.org/show_participation.php
