Jump to content

Standard SQL?


Liquid Fire

Recommended Posts

well i am build a data with pdo and want to make sure my sql statements are correct not matter the sql database the person is using.  for instance in mysql is i do:

 

SHOW TABLES LIKE 'statuses'

 

that will return statuses if the table exists and nothing if not, will that work in DB2, postgre, mssql, etc???  is there a way to test sql statement without having to install the software, something like a emulation program?

Link to comment
Share on other sites

Most popular databases don't conform to ANSI/ISO SQL by default, so it can be tricky, if not impossible, to write SQL that will work in multiple DBMSs. However, a database abstraction library like ADOdb might help you write code for database-independent systems.

Link to comment
Share on other sites

I don't think using ADOdb is that different to using PDO, they both abstract your database layer from implimentation.

 

I think its more the queries themselves the op is concerend with.

Agreed.  I really don't think you can write standard SQL statements that will span all DBMSs.  It's unfortunate but true.

Link to comment
Share on other sites

yea, i mean as far is i know all of the follow should work in all databases supported by PDO:

 

SELECT [field(s)] FROM [table][tr][td] [join_type] JOIN [table(s)] ON [field(s)] = [value(s)] WHERE [field(s)] = [value(s)] GROUP BY [feild(s)] ORDER BY [field(s)] HAVING [feild(s)]

 

INSERT INTO [table][tr][td]([fields]) (VALUE[values])

 

UPDATE [table][tr][td] SET [feild] = [value] WHERE [field] = [value]

 

DELETE FROM [table][tr][td] WHERE [fields] = [value]

 

I am just not sure about the other ones like creating/editing/deleting table and fields or adding indexs, etc...  I just want to try to find a site that lets me know how to do this kind of stuff for all major sql databases.

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.