Tag Info

New answers tagged

0

The EXPLAIN statement can be very useful when trying to track down the cause of a slow query. There's some great explanations of how to use the EXPLAIN statement and how to interpret its results here (with more real-word examples at /case{2..4}) and the official documentation here. Hope this helps!


0

Sounds like you want only the orders with a certain status/type... SELECT tblstockingorders.*, tblstatushistory.status AS actualStatus FROM tblstockingorders INNER JOIN tblstatushistory ON tblstatushistory.id=tblstockingorders.stockingorderid WHERE tblstatushistory.itemtype=2 AND tblstatushistory.status=0 editted version ...


1

I'd actually think about adding a status column to the table tblstockingorders and having a trigger on that table that injects the status into the tblstatushistory. Granted you'd have to do a 1-time update to all the rows in tblstockingorders (something similar to your query above) and set their last status, but this would give you best overall performance ...


0

I found one way that works, finally. 'm not sure why I was throwing SQL syntax errors before (I didn't save a copy of my old query attempts) but the following worked, as a JOIN inside a SUBQUERY: SELECT skill_list_expanded.description FROM skill_list_expanded WHERE skill_list_expanded.skill_id = 1 AND skill_list_expanded.subclass = 1 AND ...


0

ok i have solved it myself : UPDATE TEST SET ID = CAST(SUBSTRING(CAST(ID AS NVARCHAR(20)), 1,LEN(CAST(ID AS VARCHAR(20))) - 1) + '1' + RIGHT(CAST(ID as nvarchar(20)),1)as int)


1

You're unfortunately hitting bug 12999577 (Oracle support account required) or something close to it. And the fix for that bug introduced another bug 17564992. The workaround indicated in the first bug report is to switch the conditions around, i.e. express your where clause as 0 < ( ... ). The workaround indicated in the second is to set either of ...


1

There are many ways to do this. Most common are with a LEFT JOIN / IS NULL check, NOT IN or NOT EXISTS subquery. Here's a solution with the 3rd option: SELECT t2.id, t2.name FROM table2 AS t2 WHERE NOT EXISTS ( SELECT * FROM table3 AS t3 WHERE t3.table1_id = @t1_id -- the t1.id value (choice) that you want to check AND ...


0

Check this post out from a similar request to find records NOT IN another table. MySQL “NOT IN” query SELECT * FROM Table2 WHERE Table2.principal NOT IN (SELECT principal FROM table1) Hope that helps!



Top 50 recent answers are included