-   Linux - Software (
-   -   mysql tables with a - (

pk21 05-23-2003 04:36 AM

mysql tables with a -
Hi all,

A friend of mine made a database, but he named his tables like forum-thread. Mysql doesnt like those "-" signs in tables :(

mysql> select * from forum-thread;
ERROR 1064: You have an error in your SQL syntax near '-thread' at line 1

Does anyone know if i can adjust mysqld to accept the "-" in table names?

jharris 05-23-2003 05:00 AM

Use backticks around the table name

mysql> create table `test-table` (id int);
Query OK, 0 rows affected (0.01 sec)

mysql> drop table `test-table`;
Query OK, 0 rows affected (0.00 sec)



pk21 05-23-2003 05:02 AM

Ok, thanks.

Do i also have to use backticks in my phpscripts if i want to retrieve something from the database?

jharris 05-23-2003 05:14 AM

I would guess so as I don't think that PHP will automatically delimit this. Give it a go and see if you get an error.



pk21 05-23-2003 05:32 AM

Thanks for all the help.

But it seems this wasnt the problem, it is a query which i (and mysql) really don't understand :(

jharris 05-23-2003 05:44 AM

Why, what you trying to get working?


pk21 05-23-2003 07:23 AM

The guy who made the database and php scripts just has a query that won't work. I think the query is too large. I've advised him to use indexes. I hope it works.

jharris 05-23-2003 07:27 AM

I've never know a query be too large, although if he's not making proper use of indexes so the query is taking a long time (>30 secs by default) then PHP will time out. You can change this in your php.ini find mind you.



All times are GMT -5. The time now is 03:33 PM.