MySQL equivalent of DECODE function in Oracle
You can use IF() where in Oracle you would have used DECODE().
You can use IF() where in Oracle you would have used DECODE().
Try this OR
If you want to be correct, use INFORMATION_SCHEMA. Alternatively, you can use SHOW TABLES If there is a row in the resultset, table exists.
Sounds like they want the ability to return only allowed fields, which means the number of fields returned also has to be dynamic. This will work with 2 variables. Anything more than that will be getting confusing. Dynamic SQL will help with multiples. This examples is assuming atleast 1 column is true.
You can use PATINDEX to find the first index of the pattern (string’s) occurrence. Then use STUFF to stuff another string into the pattern(string) matched. Loop through each row. Replace each illegal characters with what you want. In your case replace non numeric with blank. The inner loop is if you have more than one … Read more
You could also try EXISTS: and per the documentation, you can SELECT anything. Traditionally, an EXISTS subquery starts with SELECT *, but it could begin with SELECT 5 or SELECT column1 or anything at all. MySQL ignores the SELECT list in such a subquery, so it makes no difference.
That syntax isn’t valid in Oracle. You can do this: Or you might be able to do this: It depends if the inline view is considered updateable by Oracle ( To be updatable for the second statement depends on some rules listed here ).
You’d need to make a User-Defined Function if you wanted to have syntax similar to your example, but could you do what you want to do, inline, fairly easily with a CASE statement, as the others have said. The UDF could be something like this: … and you would call it like so …
From the Oracle docs ROWID Pseudocolumn For each row in the database, the ROWID pseudocolumn returns the address of the row. Oracle Database rowid values contain information necessary to locate a row: The data object number of the object The data block in the datafile in which the row resides The position of the row … Read more
Starting in SQL Server 2017 the STRING_AGG function is available which simplifies the logic considerably: See SQL Fiddle with Demo In SQL Server you can use FOR XML PATH to get the result: See SQL Fiddle with Demo