I have a MySQL table which contains around 2-3 hundred thousand recors and i want to execute data fast without indexing. So how can i do that ?
i think we can use group by but not sure.
Any Help !
In the subquery, the subquery FROM has only one table, so any non-aliased column is first checked against that table. Then if that table has no such column, the external scope is checked.
One more small question : I aksed a question about update table A from table B according to certain values.
so there is this syntax :
UPDATE testA a
SET a.[Content] = b.Content
FROM testB b
WHERE a.PageID = b.pageID
AND a.PageID = 2
But another guy told me it's wrong since it's not ANSI SQL
He told me to use explicit join :
UPDATE Dest
SET [Content] = a.Content
FROM EServices_Pages_Content Dest
INNER JOIN [dstrn].weberp.dbo.EServices_Pages_Content a
ON Dest.PageID = a.pageID
...
WHERE a.PageID =2
The first one wouldn't work in Transact-SQL because of the alias a in the UPDATE clause. You could just remove the alias and replace a everywhere in that query with testA.
@RoyiNamir He probably wanted you to start using explicit joins in UPDATE instead of implicit joins. Kind of a good practice suggestion. If I were him, I'd probably first suggest an easy fix, then offer a "good practice" solution.
@AndriyM Yes I agree. I prefer to be corrected , and then be shown the other way. ( im not talking about cases where my starting point is completely wrong. my starting point was good)
Personally I don't have much against the shorter syntax. It's just that very often the updated table's name is rather long and so repeating it multiple times in fully qualified column names makes the query less readable (sometimes even longer than with the longer syntax). I'd be happy if Transact-SQL started supporting the UPDATE table AS alias syntax.
Still, being forced to use explicit joins has its benefits too. An UPDATE with an explicit join is much easier to convert to a SELECT for debugging purposes
@RoyiNamir Yes, that's what one of the articles linked by @ypercube says. The author proposes deprecation of the FROM clause in UPDATE and DELETE because it's proprietary syntax.
@RoyiNamir: To me it would seem best if you updated your answer. If I were in your situation and had just learnt what you've learnt, I would add to my self-answer that in the long run I would probably use explicit joins, explain why, credit the person who suggested that, explain the reasons why I didn't accept his answer (unaccepting his answer accordingly) and accepted my own answer.
But that's something I would do, you should decide for yourself. I'm not posting an answer because it would only correct the other answerer without suggesting anything new. That's what the comments are for and I've used them for that.
On the other hand, you could wait and see if Zohar comes up with an explanation that works for you.
@SpringLearner Sorry, I'm not sure I got it right. Your application passes strings that represent dates in the dd-mm-yyyy format to a SQL query, and you want the query to convert the strings to datetime and ultimately to float?
@ConcernedOfTunbridgeWells It never ceases to impress me that the Spectrum version of Elite managed to fit into 48K.
That's probably because you are retrieving the values as floats and do both the conversion and the formatting in the application. I've encountered this 2-day difference issue in Delphi too. I was talking about formatting only. Convert the data to datetime and return them as such. Of course, your application should read the values as datetime values too.
Still, I know little about Java, so maybe it's not very easy to set this up correctly in Java.
When you retrieve the value for the application, how do you do that? Just SELECT deliveryDate FROM tablename? (supposing deliveryDate is the column name)
public static Date convertDoubleToWindowsTime(double comTime) {
long result = 0;
comTime = comTime - 25569D;
Calendar cal = Calendar.getInstance();
result = Math.round(86400000L * comTime)
- cal.get(Calendar.ZONE_OFFSET);
cal.setTime(new Date(result));
result -= cal.get(Calendar.DST_OFFSET);
return cal.getTime();
}
sorry this is a java code
I used this first
this function accepts a double value
so I am retrieving the value from DB(which is float)
But now that you do use it, what is the issue? If you can return it as a datetime, and your application can read it correctly as a datetime, can it not format it? Do you have to format it in SQL? (That's where we started this.)
Maybe I missed something (again). Sorry if that is the case.
Your front end, when it reads CONVERT(datetime, deliveryDate), reads it as dd-mm-yyyy? It probably reads and automatically converts it into a string, correct?
And for conversion it probably uses your system locale, which is configured to use dd-mm-yyyy for dates.
@AndriyM The BBC version used to fit into 32K and they had to use a custom screen mode to save some space from the frame buffer. The top 32K of the Model B's address space was taken up by the OS and BASIC ROMs.
(source: I played Elite rather obsessively when I was 14.)
Somebody managed to get a playable chess game onto a 1K ZX81.
1K ZX Chess is a 1982 chess-playing computer program for the unexpanded Sinclair ZX81.
== Description ==
1K ZX Chess uses only 672 bytes of RAM but implements most chess rules (castling, promotion, and en passant capture are missing), and a computer opponent. It was the smallest implementation of chess on any computer until its record was broken in January 2015 by the smallest completely new PC compatible BootChess, although apparently artificial intelligence is lesser than the original.
Developer David Horne discussed 1K ZX Chess and published the full source code in a series of articles in Your...
@ypercube I can't remember ever doing self-modifying code but I can remember breaking the copy protection on various games that made use of self-modifying code to obfuscate it.
@swasheck But that would mean your report team would have to learn to program.
@ConcernedOfTunbridgeWells we have a dedicated team of well-paid report developers (read: click-and-draggers) and then a team of well-paid business analysts who click on the deployed clicked-and-dragged objects to print and then deliver them to the end-user.
@ConcernedOfTunbridgeWells was trying to solve the Knight's Tour problem. The program (in Z80A) was using around 20 bytes for code and 120 bytes for the data.
I realized shortly after running it, that the universe time would not be enough to find a solution.
@ConcernedOfTunbridgeWells "After Mel had left the company for greener pa$ture$…" – what a nice turn of a phrase and use of special symbols! Only in English.
I've got a table of invoices and customer codes. I'd like to pull only the customers that have not done any business with us since 2009.
My regular select statement is simple
SELECT INVOICE.CUSTOMER_CODE FROM INVOICES
WHERE INVOICES.ORDER_DATE <= '01-01-2010'
But, this statement also pulls c...
@ConcernedOfTunbridgeWells thnx for the story of Mel. Searching the net for the real Mel, one can find a photo of him. And also some hand written code: bemorehealthy.com/LGP-30Computer/P5300874.htm
If you think that making columns not nullable and then populating every text column with 'NONE' makes the data cleaner, you are wrong. So amazingly wrong it makes my eyes bleed. Doubly so when you realize you can't use 'NONE' in your state columns because it's varchar(2) so you use 'OO'