开发者

What does "#" signify in MySql?

开发者 https://www.devze.com 2023-01-05 18:33 出处:网络
I come from a SQL Server background and 开发者_开发技巧thought that it might mean it was a temporary table, but after reading up on MySql temp tables I don\'t think that\'s true.

I come from a SQL Server background and 开发者_开发技巧thought that it might mean it was a temporary table, but after reading up on MySql temp tables I don't think that's true.

I'm seeing it in the following context:

SELECT ID, Name FROM #_SomeName

UPDATE

This query is defined in a PHP string and then run against the MySQL Database. I'm not sure if that would make a difference or not...

here is the PHP code i'm running:

$query="select id, name from #__SomeName";
$db=&JFactory::getDBO();
$db->setQuery($query);


In MySQL # is an end-of-line comment:

http://dev.mysql.com/doc/refman/5.1/en/comments.html

In JFactory, #__ is used as a place holder. See here:

http://docs.joomla.org/How_to_use_the_database_classes_in_your_script


A Comment

# comment
-- also a comment

The syntax highlighting answers the question ;)


are you sure the table name is not quoted using backticks? maybe in the issuing application? it might show up in MySQL's query log bare.

mysql> create table `#t` (i int);
mysql> insert into `#t` (i) values (10);
mysql> select * from `#t`;
+------+
| i    |
+------+
|   10 | 
+------+


It's usually a comment character. Are there more lines to your script? Basically, I'd expect something like this:

SELECT id, name, whatever FROM #_table
my_table WHERE id = 7;

Maybe someone commented out the old table name and put a new one in?

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号