This question already has answers here:
Does SQLite support "delete from from"
(2 answers)
Closed 8 years ago.
I am performing this SQLite command:
DELETE FROM t1027 INNER JOIN translationsmain ON t1027.textid=translationsmain.textid WHERE translationsmain.osb=0
The column "textid" exists both in the table "t1027" and in "translationsmain".
The column "osb" only exists in "translationsmain".
I am getting a syntax error, but I am not sure why.
I am getting a syntax error, but I am not sure why.
Simply, because such syntax is not allowed by SQLite.
Use this syntax, instead:
DELETE FROM t1027 WHERE textid IN (SELECT textid FROM translationsmain WHERE osb = 0)
Related
This question already has answers here:
Overwrite only some partitions in a partitioned spark Dataset
(3 answers)
Closed 4 years ago.
I'm using the spark_write_table function from sparklyr to write tables into HDFS, using the partition_by parameter to define how to store them:
R> my_table %>%
spark_write_table(.,
path="mytable",
mode="append",
partition_by=c("col1", "col2")
)
However, now I want to update the table by altering just one partition, instead of writing the whole table again.
In Hadoop-SQL I would do something like:
INSERT INTO TABLE mytable
PARTITION (col1 = 'my_partition')
VALUES (myvalues..)
Is there an equivalent option to do this in sparklyr correctly? I cannot find it in the documentation.
Re - duplication note: this question is specifically about the way to do this in R with the sparklyr function, while the other question is about general Hive syntax
Thanks all for the comments.
It seems there is no way to do this with sparklyr directly, but this is what I am going to do.
In short, I'll save the new partition file in a temporary table, use Hadoop SQL commands to drop the partition, then another SQL command to insert into the temporary table into it.
> dbGetQuery(con,
"ALTER TABLE mytable DROP IF EXISTS PARTITION (mycol='partition1');")
> spark_write_table(new_partition, "tmp_partition_table")
> dbGetQuery(con,
"INSERT VALUES INTO TABLE mytable
PARTITION (mycol='partition1')
SELECT *
FROM tmp_partition_table "
)
This question already has an answer here:
SQLite FireDAC trailing spaces
(1 answer)
Closed 5 years ago.
In my case, I have lost a symbol $A at the end of line when I get field in Delphi. I think, Problem is in FireDac components. I use Delphi 10.1 Berlin and Sqlite (I don't know a version). When I start up program below, I have result 3!=4 in message.
This is code:
FD := TFDQuery.Create(nil);
FD.Connection := FDConnection1;
FD.ExecSQL('create table t2 (f2 text)');
FD.ExecSQL('insert into t2 values(''123''||char(10))');
FD.Open('select f2, length(f2) as l from t2');
ShowMessage(IntToStr(Length(FD.FieldByName('f2').AsString))+'!='+FD.FieldByName('l').AsString);
Last symbol $A lost.
May be somebody explain me this strange behavior.
You need to turn off the TFDQuery.FormatOptions.StrsTrim property:
Controls the removing of trailing spaces from string values and zero bytes from binary values
...
For SQLite, this property is applied to all string columns
This question already has answers here:
Symfony2 QueryBuilder join ON and WITH difference
(2 answers)
Closed 5 years ago.
I wondering about this line
->leftJoin(
'AppBundle\Entity\UserGroups',
'UserGroups',
\Doctrine\ORM\Query\Expr\Join::WITH,
'User.group_id = UserGroups.id'
);
This works fine, the result is okay.
But when I replace ::WITH with ::ON this causes an error:
Error: Expected Doctrine\ORM\Query\Lexer::T_WITH, got 'ON'
So what are difference between ::WITH and ::ON ?
Look here:
https://github.com/doctrine/doctrine2/blob/master/lib/Doctrine/ORM/Query/Lexer.php
T_ON is not even a valid constant inside Doctrine's Lexer class, which is why you are seeing the error.
This question already has answers here:
How delete table inner join with other table in Sqlite?
(2 answers)
Closed 6 years ago.
Why am I getting an error with this statement?
Error: could not prepare statement (1 near "t3": syntax error)
(Note: tables renamed for simplicity)
DELETE FROM table3 t3
INNER JOIN table2 t2 ON t2.tempId = t3.tempId
INNER JOIN table1 t1 ON t1.tempId = t2.tempId
WHERE t1.tempId = 9;
"Heh ..." I don't think that the DELETE statement knows anything about "joins" ...
... and I sure-as-heck think that I understand *why (not)."
Instead, do this:
Start a transaction.
Run a SELECT query to obtain a list of record-IDs that meet your
selection criteria.
"Aww, heck ..." Go ahead and dump a list of those record-IDs to some log-file somewhere ....
Execute a series of DELETE queries to delete these IDs.
COMMIT. (Or, if anything-at-all goes wrong, ROLLBACK.)
This question already has answers here:
Is it possible to insert multiple rows at a time in an SQLite database?
(25 answers)
Closed 4 years ago.
I searched the hinted posts, when posting this question but I foud none similar, so I apologize if I missed any.
Here's my problem. I created a table and it's fields, in SQLite Administrator, then I wrote the following query to populate the table:
USE Contact_Database;
INSERT into Names (Contact_ID, FirstName, LastName) VALUES
(1, 'Joana', 'Tavares'),
(2, 'Patrícia', 'Dias'),
(3, 'Paulo', 'Costa'),
(4, 'Marco', 'Almeida'),
(5, 'Bruno', 'Lindo'),
(6, 'Manuela', 'Lindo'),
(7, 'João', 'Lindo'),
(8, 'Rui', 'Trindade');
Result error: SQL Error: near "USE": syntax error
I've also tried with:
INSERT into Contact_Database.Names
Result error: SQL Error: near ",": syntax error <
What am I missing here?
Multiple inserts in one query are not supported.
See this question for more information.
I had same problem but I solved it while I ignore (delete) the insertion query during creating table.
I changed this
db.execSQL("INSERT INTO MessageTable VALUES(datetime(),'Pir Fahim',00923359110795','Hello,testing');");
to:
db.execSQL("INSERT INTO CallTable VALUES('"+call_time+"','"+name+"','"+phone_no+"','"+interface_style+"','"+tone+"','"+voice_path+"','"+vibration_mode+"');");