straight forward question, but interesting enought, I didn't find anything. Probably I'm searching for the wrong keywords:
We have 2 Databases, one Oracle, one SQL, connected via Links.
I'd like to check, if some data is in the Oracle-Part, but not in the SQL one.
Selecting it from the PLSQLDev is pretty straightforward:
SELECT * from Core.Event#Link
But as soon as I try to select specific fields like :
SELECT Id from Core.Event#Link
It tells me the qualifier is invalid.
I tried all shennanigans like alias select:
SELECT ie.Id from Core.Event#Link ie
But it keeps telling me the qualifier is invalid.
Is there a special syntax I have to keep in mind?
Thanks in advance and a good weekend.
Matthias
Related
I would like to execute a SQL command. However, the keywords may contain errors. For example, the correct command should be
select id from my_table where name = 'Tommy'
It would return 1.
However, if someone execute the following incorrect command:
select id from my_table where name = 'Tomyy'
How to change the command so that it still returns 1?
Thanks a lot.
There are many ways to tackle these, but please keep in mind this isn't the easiest of tasks. What you're looking for is a fuzzy search algorithm.
This should get you started: Fuzzy searches in SQL Server (Redgate)
Code project also has some interesting options here: Implementing phonetic name searches
If you're looking for an easier but more barebones solution you should look into using SOUNDEX or DIFFERENCE (assuming your dbms is MSSQL). I've been playing a bit with DIFFERENCE and it's pretty cool what this can do out of the box.
Try this
select id from my_table where SOUNDEX(name) = SOUNDEX('Tomyy')
In SQL Server, I am trying to select some of the records using a string which has space so I trim and use but something is wrong please correct me where something is missed by me.
SELECT * FROM projects where str_id=ltrim(rtrim(' artf130 ')) --- No rows selected
SELECT * FROM projects where str_id='artf130' -- one row selected
Update: I copied the first line from google spread sheet.
Maybe that was my bad. People keep helping.
I think my comment was enough, cause I linked to a very similar problem, which got a answer. So here for everyone:
You can see the answer to that question here.
Just inherited an Access database and trying to figure some things out. For the life of me, I have no idea what this query means.
SELECT [col1]/[col2].[col3]...
Its like the [col1]/[col2] is the table name and [col3] is the column. But instead of a table, it is math function (dividing two columns) followed by the column name. SELECT table.column....
I thought this might be inherent to someone with Access experience (or maybe this is some SQL that I am not familiar with). If it is not just comment and I will post all of the info.
SELECT [coly]/[table].[colx]...
I have to write a select statement following the following pattern:
[A-Z][0-9][0-9][0-9][0-9][A-Z][0-9][0-9][0-9][0-9][0-9]
The only thing I'm sure of is that the first A-Z WILL be there. All the rest is optional and the optional part is the problem. I don't really know how I could do that.
Some example data:
B/0765/E 3
B/0765/E3
B/0764/A /02
B/0749/K
B/0768/
B/0784//02
B/0807/
My guess is that I best remove al the white spaces and the / in the data and then execute the select statement. But I'm having some problems writing the like pattern actually.. Anyone that could help me out?
The underlying reason for this is that I'm migrating a database. In the old database the values are just in 1 field but in the new one they are splitted into several fields but I first have to write a "control script" to know what records in the old database are not correct.
Even the following isn't working:
where someColumn LIKE '[a-zA-Z]%';
You can use Regular Expression via xQuery to define this pattern. There are many question in StackOverFlow that talk about patterns in DB2, and they have been solved with Regular Expressions.
DB2: find field value where first character is a lower case letter
Emulate REGEXP like behaviour in SQL
Looking at this link: SQL SELECT LIKE
What if you were searching for a name that starts with H and ends with dinger?
Would I use:
SELECT NAME LIKE
'H_dinger'
'H...dinger' or
'H%dinger' ?
I'll assume H_dinger would think there is only 1 character in between, but I don't know what it is -- so I'm searching for it.
H...dinger isn't valid.
And H%dinger seems like it would check it all, but on the site, that isn't even listed?
You would use %, which is the variable-sized wildcard.
But you need to get the syntax right, such as with:
select NAME from TABLE where NAME like 'H%dinger'
Keep in mind that queries using % may be a performance issue (depending on how it's used and the DBMS engine). It can prevent the efficient use of indexes to speed up queries. It probably won't matter for small tables but it's something to keep in mind if you ever need to scale.