Here is the link to my sql code
https://www.mycompiler.io/view/5Lecen1
I don't know why but this is giving error when I am running it in an online sql compiler. It is giving a syntax error but when I am removing the operator "some" it is working fine. This is happening only when I use "some or any" keywords in subqueries can someone please help me find out what am I doing wrong
Syntax for SOME specifies the equality operator as '=', not '==':
https://dev.mysql.com/doc/refman/8.0/en/any-in-some-subqueries.html
Related
I'm trying to execute the query below but WorkBench keeps complaining about a syntax error (Error 1064). I don't know what the error is because even WorkBench highlights each bracket pair and so I can't say there is a missing bracket. Please help.
SELECT
If(Right(Trim(`tbloldfurniture`.`NotesOnOldness`), 4) = 'susp', Substring(Trim(`tbloldfurniture`.`NotesOnOldness`), 1, Char_Length(Trim(Lower(`tbloldfurniture`.`NotesOnOldness`)) - 1)) ,Substring(Trim(Lower(`tbloldfurniture`.`NotesOnOldness`))))
FROM `tbloldfurniture`;
This is the same query broken into its separate parts to aid readability.
SELECT
If(
Right(Trim(`tbloldfurniture`.`NotesOnOldness`), 4) = 'susp',
Substring(Trim(`tbloldfurniture`.`NotesOnOldness`), 1, Char_Length(Trim(Lower(`tbloldfurniture`.`NotesOnOldness`)) - 1)) ,
Substring(Trim(Lower(`tbloldfurniture`.`NotesOnOldness`)))
)
FROM `tbloldfurniture`;
MySQL's substring() function expects at least two parameters and you're feeding it just one in Substring(Trim(Lower(tbloldfurniture.NotesOnOldness))).
Also, you're probably doing something wrong, as you're deducting 1 from a string in Char_Length(Trim(Lower(tbloldfurniture.NotesOnOldness)) - 1).
And yeah, SQL is notoriously terrible with its error messages. Confusing as heck.
The 1064 error is a syntax error. This means the reason there’s a problem is because MySQL doesn’t understand what you’re asking it to do. Cant see an issue with what you have put tho. If your query attempts to reference information in a database and can’t find it, that could be the issue ?
Hello Team I new to ACCESS, getting a syntax error for the below query
I think your problem is all the double quotation marks. Try this:
SELECT HRMNZ_TRF_SCH.HRMNZ_TRF_SCH_NO, HRMNZ_TRF_SCH.SCH_B_CMDTY_CD, CAT_ID_HTSUSA_XREF.CAT_ID_NO_20, CAT_ID_HTSUSA_XREF.LAST_UPDT_TS, CAT_ID_HTSUSA_XREF.LAST_UPDT_LOGON_ID
FROM Z1TJ111$.HRMNZ_TRF_SCH HRMNZ_TRF_SCH INNER JOIN Z1TJ111$.CAT_ID_HTSUSA_XREF.CAT_ID_HTSUSA_XREF ON HRMNZ_TRF_SCH.HRMNZ_TRF_SCH_NO=CAT_ID_HTSUSA_XREF.HRMNZ_TRF_SCH_NO
WHERE NOT (HRMNZ_TRF_SCH.HRMNZ_TRF_SCH_NO='7211.23.3000' OR HRMNZ_TRF_SCH.HRMNZ_TRF_SCH_NO='8427.20.8000' OR HRMNZ_TRF_SCH.HRMNZ_TRF_SCH_NO='8427.90.0000' OR HRMNZ_TRF_SCH.HRMNZ_TRF_SCH_NO='8525.50.7010' OR HRMNZ_TRF_SCH.HRMNZ_TRF_SCH_NO='8525.60.1050' OR HRMNZ_TRF_SCH.HRMNZ_TRF_SCH_NO='8526.10.0040' OR HRMNZ_TRF_SCH.HRMNZ_TRF_SCH_NO='8526.91.0020' OR HRMNZ_TRF_SCH.HRMNZ_TRF_SCH_NO='8526.91.0040' OR HRMNZ_TRF_SCH.HRMNZ_TRF_SCH_NO='8527.99.1500' OR HRMNZ_TRF_SCH.HRMNZ_TRF_SCH_NO='9014.10.7080') AND HRMNZ_TRF_SCH.HRMNZ_TRF_SCH_NO<>HRMNZ_TRF_SCH.SCH_B_CMDTY_CD
Use the query editor to get tips about what is wrong. If you don't know how here is a tutorial: https://www.tutorialspoint.com/ms_access/ms_access_sql_view.htm
I used this query to get a regular expression with successful results.
select * from paso_string where 'AAAAAAAAA' SIMILAR TO columname
But, When I use this query into ingres 4GL show me an error when I try to compiling and show me the follow issue.
E_OS0100 Syntax error on line
The last symbol read was 'similar'
4GL has its own parser, which sadly is often behind the SQL parser when it comes to new features.
The standard work-around is to put your SQL statement into a string and then do execute immediate :string;
I running a Mysql Query to select some data, Sometimes i get a error called
mysql_fetch_assoc() expects parameter 1 to be resource, boolean given
when i executed this following code,
$result = $this->db->execute($sql);
for ($i = 0; $data[$i + 1] = mysql_fetch_assoc($result); $i++);
array_pop($data);
how do i optimize this coding to prevent any errors ?
is there anything wrong with it ? should i ignore this error ?
That means that the query is buggy, whyever, most likely because you construct it using components from sources which you do not really check enough. A buggy statement throws an error (since no result can be computed). That error is returned as false instead of a mysql result ressource. Since you do not check if the query succeeded but blindly try to retrieve details from the result, you get this second error.
So there are four things you have to invest into:
you should always check if a query succeeded at all:
enclose your query into a conditional: if (FALSE!==($result=$this->db->execute($sql))) and only retrieve from the result ressource if that condition resolves to true.
make sure you really (really!) check all input data you use to construct your query. Checking here also means to encode and escape it correctly, also see point 4. for this.
in cases like this it is important to analyze what exactly it is that is going wrong. There is little sense in guessing what might be going wrong. So in addition to checking if the query succeeded at all (1.) you should also take a look at the error message mysql throws if this is not the case. Use the method mysql_error() for this. It is well documented just as every other function too.
you should rework your code and migrate from phps old, long deprecated mysql extension to either mysqli or PDO. Both are php extensions that offer more security against constructing buggy statements. Read about "prepared statements" and "parameter binding" for this.
I am executing the follow mysql query and getting error saying wrong syntax.
SELECT COUNT(*) FROM PS.INFO WHERE IPADDRESS='1.1.1.1' AND ID='YYY' AND (TYPE='PAID' 0R TYPE='FREE') AND EXPIRYTIME IS NULL;
Please help me out with the correct syntax?
Your wrote 0R (zero-R) instead of OR (O-R).
TYPE='PAID' 0R TYPE='FREE'
OR
appears to have a zero instead of an O
The error always tells you where to look. In this case it says "near '0R..."
And sure enough, that's a zero, not an O. It should be the word OR.