Jump to content

MySQL Statements


shane18

Recommended Posts

what if you have a table called "from"? a statement like "SELECT * FROM from" will not execute. "SELECT * FROM `from`" would work.

 

I doubt it if you can name a table "from", I think "from" is a reserved word in MySQL, therefore your example is not even right to begin with.

 

For the future, if this thing happens in the later versions of MySQL, people won't use it and it will fail because people will stick to the older version because their sites are coded without ` so they are not going to go to each and every SQL statement and add this ` to each and every field and table, this is ridiculous.

 

Even if they did that, then they will be repeating the same mistake with XHTML 1.1 and XTHML 2.0

 

cheers!

Link to comment
Share on other sites

what if you have a table called "from"? a statement like "SELECT * FROM from" will not execute. "SELECT * FROM `from`" would work.

 

I doubt it if you can name a table "from", I think "from" is a reserved word in MySQL, therefore your example is not even right to begin with.

 

Do you doubt this from your extensive knowledge of databases and in particular mysql? Please. Why don't you try it yourself. "create table `from`(test int primary key)". That's exactly why you would use ` because IT IS A RESERVED WORD.

Link to comment
Share on other sites

what if you have a table called "from"? a statement like "SELECT * FROM from" will not execute. "SELECT * FROM `from`" would work.

 

 

I doubt it if you can name a table "from", I think "from" is a reserved word in MySQL, therefore your example is not even right to begin with.

 

Do you doubt this from your extensive knowledge of databases and in particular mysql? Please. Why don't you try it yourself. "create table `from`(test int primary key)". That's exactly why you would use ` because IT IS A RESERVED WORD.

 

 

excuse me, my knowledge is not extensive in SQL, I have not written any SQL statement in ages, however, why would a reasonable programmer give a table such name? a reversed word? don't tell me that he ran out of words lol.

 

This way he is forcing himself to use this ` in each and every statement in his SQL's which sucks.

 

Anyway, you need to take care of millions of web sites that have their SQL's without ` and convience them all to rewrite their code or look for every piece of SQL in their code.

 

good luck for those who want to put ` in their SQL, I promise I won't put any lol, in fact I don't even write SQL's but even if I have to, I won't because its ridiculous. 

Link to comment
Share on other sites

what if you have a table called "from"? a statement like "SELECT * FROM from" will not execute. "SELECT * FROM `from`" would work.

 

 

I doubt it if you can name a table "from", I think "from" is a reserved word in MySQL, therefore your example is not even right to begin with.

 

Do you doubt this from your extensive knowledge of databases and in particular mysql? Please. Why don't you try it yourself. "create table `from`(test int primary key)". That's exactly why you would use ` because IT IS A RESERVED WORD.

 

 

excuse me, my knowledge is not extensive in SQL, I have not written any SQL statement in ages, however, why would a reasonable programmer give a table such name? a reversed word? don't tell me that he ran out of words lol.

 

This way he is forcing himself to use this ` in each and every statement in his SQL's which sucks.

 

Anyway, you need to take care of millions of web sites that have their SQL's without ` and convience them all to rewrite their code or look for every piece of SQL in their code.

 

good luck for those who want to put ` in their SQL, I promise I won't put any lol, in fact I don't even write SQL's but even if I have to, I won't because its ridiculous.

 

It basically only sucks ONCE when you write your application. "from" would seem like a popular table name choice to me, even though i personally wouldn't use it. its also comparable to using {} to mark variables within a PHP string i.e. $mad_lib = "The bread basket was full of {$adjective} bread..." Some people dont do it, or dont like it, but I like it because its easier to pick apart variables just by scanning it quickly. Same with `

Link to comment
Share on other sites

As said before, backticks (``) are used to indicate that given word is a table/column identifier. Using it you can call your tables with reserved words, use whitespace in names or even call your table `.` if you're crazy enough (don't try it at home, I did it for you). For portability reasons (ability to move your application to different database systems) backticks should NOT be used (because (1) they're not part of stadard SQL, and (2) it forces you to give sensible names to your tables/columns)

Link to comment
Share on other sites

For portability reasons (ability to move your application to different database systems) backticks should NOT be used (because (1) they're not part of stadard SQL, and (2) it forces you to give sensible names to your tables/columns)

 

This should be enough for these clumsy backticks to not to be used.

 

I own you one Mchl.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.