[sqlite] What query should I use?
Hi, I have a table with a following data: IdText1 Text2 Text3 Text4 --- 11001 11 test03 test13 21002 11 test01 test11 31003 12 test04 test12 41004 12 test02 test34 51004 12 test06 test56 61005 11 test17 test67 71005 12 test07 test57 81006 13 test05 test98 91007 13 test02 test93 10 1008 14 test01 test03 ... ..... .. Now, I would like to select only the rows when Text2 change. So the result of such query should look like: IdText1 Text2 Text3 Text4 --- 11001 11 test03 test13 31003 12 test04 test12 61005 11test17 test67 71005 12 test07 test57 81006 13 test05 test98 10 1008 14 test01 test03 ... ..... .. How should this query look like? Regards Wojciech W. - To unsubscribe, send email to [EMAIL PROTECTED] -
RE: [sqlite] Re: Why it does not work properly?
Thank you very much Igor!!, Your advices were very helpful. Do you know some good literature to learn/improve SQL knowledge ?? Best reg. Wojciech W. -Original Message- From: Igor Tandetnik [mailto:[EMAIL PROTECTED] Sent: Monday, March 05, 2007 2:21 PM To: SQLite Subject: [sqlite] Re: Re: Why it does not work properly? woj <[EMAIL PROTECTED]> wrote: > Thank's for your reply. I didnt realize this, but of course it is > logical. So, now I think how to select not only one row (what seems > to be easy) but set of rows from previously mentioned data where only > these rows are picked up with largest Data value for each IdMat, so > correct version of querry: > SELECT Mieszalnia.IdMat, Mieszalnia.Partia, Mieszalnia.Kont, > Mieszalnia.Uk, Max(Mieszalnia.Data) FROM Mieszalnia GROUPED BY > Mieszalnia.IdMat; I'm not sure if this was meant as a question or a statement. In case it was in fact a question, consider this: select IdMat, ..., Data from Mieszalnia m1 where not exists ( select * from Mieszalnia m2 where m2.IdMat = m1.IdMat and m2.Data > m1.Data ); Igor Tandetnik - To unsubscribe, send email to [EMAIL PROTECTED] - - To unsubscribe, send email to [EMAIL PROTECTED] -
[sqlite] What query?
Hi, I have a table with a following data: IdNo1 No2 11001 11 21002 11 31003 12 41004 12 51004 12 61005 12 71006 13 81007 13 91008 14 ... ... Now, I would like to select only the rows when No2 change. So the result of such query should look like: IdNo1 No2 11001 11 31003 12 71006 13 91008 14 ... ... How should this query look like? Regards Wojciech - To unsubscribe, send email to [EMAIL PROTECTED] -
[sqlite] Problem with (??) INNER JOIN
Hi sqlite-users, I have a following problem. In my database there are 3 table: CREATE TABLE [Samochody] ( [IDsam] integer, [Samochod] varchar (50), PRIMARY KEY ([IDsam]) ); CREATE TABLE [Modele] ( [IDmod] integer, [IDsam] integer, [Model] varchar (50), PRIMARY KEY ([IDmod]) ); CREATE TABLE [PomiarBledow] ( [IDpomiaru] integer, [IDmod] integer, [IDkol] integer, PRIMARY KEY ([IDpomiaru]) ); In tables are some hypothetical data: INSERT INTO [Samochody] ([Samochod]) VALUES ('Number1'); /-> IDsam=1; INSERT INTO [Modele] ([IDsam], [Model]) VALUES ('1', 'Bus'); /-> IDmod=1; INSERT INTO [Modele] ([IDsam], [Model]) VALUES ('1', 'Truck'); /-> IDmod=2; INSERT INTO [PomiarBledow] ([IDmod], [IDkol]) VALUES ('1', '1'); /-> IDpomiaru=1; INSERT INTO [PomiarBledow] ([IDmod], [IDkol]) VALUES ('1', '2'); /-> IDpomiaru=2; INSERT INTO [PomiarBledow] ([IDmod], [IDkol]) VALUES ('2', '4'); /-> IDpomiaru=3; INSERT INTO [PomiarBledow] ([IDmod], [IDkol]) VALUES ('2', '5'); /-> IDpomiaru=4; Now I try to execute SQL query: SELECT PomiarBledow.IDpomiaru, Samochody.Samochod FROM (PomiarBledow INNER JOIN Modele ON PomiarBledow.IDmod = Modele.IDmod) INNER JOIN Samochody ON Modele.IDsam = Samochody.IDsam WHERE (((PomiarBledow.IDpomiaru)=2)); and I get en error: "Error 1 - No such column: PomiarBledow.IDpomiaru" In MSAccess there is no problem to execute such query. What is wrong with it? Regards WojciechW.
RE: [sqlite] Probably not simple question
Hallo, Thanks a lot, finally everything works well. Indeed, I have to learn much about SQL database usage, so sorry for that question. Regards WojciechW -Original Message- From: Wilson Yeung [mailto:[EMAIL PROTECTED] Sent: Thursday, December 08, 2005 7:38 PM To: sqlite-users@sqlite.org Cc: [EMAIL PROTECTED] Subject: Re: [sqlite] Probably not simple question The setBinary() method takes two arguments, the unsigned char * the size of the blob as a size_t. You're expected to cast your structure into an unsigned char *, because in C/C++, the only portable way to represent a byte is with a char/unsigned char. And really, what is your structure but a sequence of bytes? So, for example: struct intDouble myIntDouble; myIntDouble.x = 1; myIntDouble.y = 2; CppSQLiteBinary blob; blob.setBinary((unsigned char *) myIntDouble, sizeof(struct intDouble)); SQLite is really no different than many other SQL databases in this respect, and I think you would be better off picking up a book on SQL, walking through a tutorial on SQL, and SQL database usage, learning about indexes, datatypes, blobs, transactions, etc. This mailing list can certainly answer questions about SQLite, how it's different than other databases, and how to use SQLite specifically. But this mailing list probably isn't going to do a good job at showing you how to use a SQL database in general. Cheers, Wilson
Re: [sqlite] Probably not simple question
I have follow your advice and had a look at CppSQLite. setBinary and getBinary functions work only on unsigned char, and size of intDouble is (on my PC) 8 bytes, so much more than unsigned char (1 byte). The question is how to correctly store such structure in db, and how to restore it later? Regards WojciechW
[sqlite] A newbie question
Hi all, so I have a (not) simple question. Is it possible to insert into blob field content of the file? How to = manage it in C++? Regards WojciechW