LEFT function in Oracle

There is no documented LEFT() function in Oracle. Find the full set here. Probably what you have is a user-defined function. You can check that easily enough by querying the data dictionary: But there is the question of why the stored procedure works and the query doesn’t. One possible solution is that the stored procedure is … Read more

How to create id with AUTO_INCREMENT on Oracle?

There is no such thing as “auto_increment” or “identity” columns in Oracle as of Oracle 11g. However, you can model it easily with a sequence and a trigger: Table definition: Trigger definition: UPDATE: IDENTITY column is now available on Oracle 12c: or specify starting and increment values, also preventing any insert into the identity column … Read more

How to do Select All(*) in linq to sql

Or just: In method syntax, with other operators: Essentially, you already are selecting all columns, the select then transforms that to the columns you care about, so you can even do things like:

ROW_NUMBER() in MySQ

I want the row with the single highest col3 for each (col1, col2) pair. That’s a groupwise maximum, one of the most commonly-asked SQL questions (since it seems like it should be easy, but actually it kind of isn’t). I often plump for a null-self-join: “Get the rows in the table for which no other … Read more

Equivalent of explode() to work with strings in MySQL

MYSQL has no explode() like function built in. But you can easily add similar function to your DB and then use it from php queries. That function will look like: Usage: The example above will return apple. I think that it will be impossible to return array in MySQL so you must specify which occurrence … Read more

DATEDIFF function in Oracle

In Oracle, you can simply subtract two dates and get the difference in days. Also note that unlike SQL Server or MySQL, in Oracle you cannot perform a select statement without a from clause. One way around this is to use the builtin dummy table, dual:

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)