I'm trying to valid a SQL injection challenge on root-me.org. I want to retrieve the databases names with the command
1' SELECT * FROM my_db.sqlite_master WHERE type='table';
But i get the following error: SQLite3::query(): Unable to prepare statement: 1, near "SELECT"
Any idea ?
SELECT name
FROM master.dbo.sysdatabases
Possible duplicate of
sqlite3 - how to list out database name using .databases command?
Related
In MS Access, I created a query by create Menu-> Query Design (with name Query3).
I want use it in an SQL command in another query but when I run it got this error:
Syntax error on query expression 'select f1'
SQL command
INSERT INTO boors (boors.Nemad, boors.Volumn, boors.Price,
boors.LastPrice, boors.LastPerc, boors.LastPr,
boors.LastPer, boors.MinPrice, boors.MaxPrice,
boors.distance, boors.inout, boors.Power)
values (select f1,f2,f3,f4,f5,f6,f7,f8,f9,f10,f11,f12 FROM Query3)
It appears that you are mixing the SQL used for inserting values and inserting from a table/query. As you are doing the latter, your SQL should look like:
INSERT INTO boors (Nemad, Volumn)
SELECT F1, F2
FROM Query3
Regards,
I am trying to select a single column in my data table using raw SQL in a postgresql database from the psql command line. I am getting an error message that says the column does not exist. Then it gives me a hint to use the exact column that I referenced in the select statement. Here is the query:
SELECT insider_app_ownershipdocument.transactionDate FROM insider_app_ownershipdocument;
Here is the error message:
ERROR: column insider_app_ownershipdocument.transactiondate does not exist
SELECT insider_app_ownershipdocument.transactionDate FROM in...
HINT: Perhaps you meant to reference the column "insider_app_ownershipdocument.transactionDate".
I have no idea why this is not working.
(Postgres) SQL converts names automatically to lower case although it support case-sensitive names. So
SELECT insider_app_ownershipdocument.transactionDate FROM insider_app_ownershipdocument;
will be aquivalent to:
SELECT insider_app_ownershipdocument.transactiondate FROM insider_app_ownershipdocument;
You should protect the column name with double quotes to avoid this effect:
SELECT insider_app_ownershipdocument."transactionDate" FROM insider_app_ownershipdocument;
In BigQuery I am using the following query:
SELECT
*
FROM
`properati-data-public:properties_mx.properties_sell_201***`
WHERE
_TABLE_SUFFIX BETWEEN '1501'
AND '1810'
Where properati-data-public:properties_mx.properties_sell_201501 is a valid table. When I use the query with multiple tables, I get the following error:
Query Failed
Error: Invalid table name: `properati-data-public:properties_mx.properties_sell_201***`
you should use:
`properati-data-public.properties_mx.properties_sell_20*`
Note:
. vs. :
20* vs. 201***
Also put below as a first line in your query to assure you are in Standard SQL mode
#standardSQL
In SSMS 2012, I have created a linked server in SERVERA to SERVERB from which I have successfully written queries to multiple tables within the DBB database using a four part reference.
When I try to reference the 'Charge' table in the 'DBB' database with a simple select statement:
SELECT * FROM [SERVERB].[DBB].dbo.Charge
I get the following message:
Msg 207, Level 16, State 1, Line 1 Invalid column name 'charge_type'.
This column exists in the DBB database as 'Charge_Type', however, the collation of SERVERB is case insensitive, whereas the collation of SERVERA is case sensitive (which is where, I believe, my problem lies).
Does anyone have experience with this issue?
(For the people who might end up here)
You can change the collation on the fly. In this case, you have to write the name of the column names in the select query. What I mean is,
rather than writing query like this:
SELECT * FROM [SERVERB].[DBB].dbo.Charge
write the query like this:
SELECT Charge_Col1, Charge_Col2, Charge_Type COLLATE Latin1_General_CI_AS FROM [SERVERB].[DBB].dbo.Charge
There is another post similar to this: how we can select two columns having different collation
I want to be able to create new tables based on any SQL select statement. I have tried the following which I got the format from another question and it does not work (there are similar questions but not one that I found actually works). I keep getting an error on the SQL statement.
Msg 156, Level 15, State 1, Line 2
Incorrect syntax near the keyword 'AS'.
This is the CREATE TABLE statement:
CREATE TABLE MyNewTable
AS
SELECT *
FROM dbo.Bat
This will copy the entire table including rows
SELECT *
INTO newTableName
FROM dbo.Bat
Add WHERE 1 = 0 to copy just the table structure
If it is SQL Server (the dbo schema, default in SQL Server indicates it is SQL Server), you can do following.
select * into MyNewTable from dbo.Bat;
The SELECT INTO statement does not copy your table constraints.
You statement is a valid Oracle and MySQL statement though.
CREATE TABLE ... AS SELECT is simple (by deliberately ignoring for example the concepts of storage)
To create a table with all its lines
code:
CREATE TABLE XX AS SELECT * FROM YY ;
the result of command in mysql