cancel
Showing results for 
Search instead for 
Did you mean: 

Understanding SQL syntax difference between MySQL and SQLAnywhere (PHP)

Former Member
0 Kudos
9,496

I've inherited a SQLAnywhere database that somebody else created. I'm more used to MySQL. I'm able to connect and query both databases.

Example of a working query for the MySQL database:

{
  $query = DB::query('SELECT * FROM `Users`');
}

Example of a working query for the SQLAnywhere database:

{
  $query = DB::query('SELECT * FROM "EM"."Users"');
}

My question is about what the 'EM.' prefix is:

  • is this a table prefix?
  • is it required?
  • can the separator (period) be changed to another symbol?
  • where in Sybase Central can the prefix name be edited?
  • if it's not required, how can I remove it?
  • if it is required, how do I manage my code to keep the SQL statements portable?

Accepted Solutions (1)

Accepted Solutions (1)

MCMartin
Participant

The EM is the name of the table owner, if your user is not EM or in the group of EM you need the right to access the table and also need to address the table with the owner. From the docs:

"Tables owned by a different user can be qualified by specifying the user ID. Tables owned by groups to which the current user belongs are found by default without specifying the user ID."

Former Member
0 Kudos

Thanks. This helped me establish that if I log in as the user 'EM' I can now run the query like this:

{
  $query = DB::query('SELECT * FROM "Users"');
}

Which is what I wanted.

Answers (0)