I'm retrieving data from Excel from my asp.net page
The WorkSheet name is StatusPasPorts.
When I remove the column [Account Reference No.] it does work fine, but if I
use it I get
error : '' is not a valid name. Make sure that it does not include invalid characters or punctuation and that it is not too long.
SELECT [Event Date],[Mobile Number],[Event Type Name],[Identification Method],[Customer DOB],[Account Reference No.] FROM [StatusPasPorts$] where Date] ASC
Any ideas what is missing?
Try removing the dot at the end of the column name - 'Account Reference No.'
Name it as 'Account Reference No'
Related
I have a table with an url column with urls like so:
https://shop.domain.com/product/12345/this-is-great-product
I need to extract the last part from the last slash to the end:
this-is-great-product
I was planning in using something REGEXP_SUBSTR but its an extension that I don want to install.
How can i do this in SQLite version 3.39.4 ?
You can use JSON: convert your delimited string (url) into a valid JSON array, then take the last element:
CREATE TABLE IF NOT EXISTS urls(url);
DELETE FROM urls;
INSERT INTO urls(url) VALUES ('https://shop.domain.com/product/12345/this-is-great-product');
SELECT json_extract('["' || replace(url, '/', '", "') || '"]', '$[#-1]') AS suffix FROM urls;
See the fiddle.
I am creating a report from a query where a field ABC is displayed as CAT if yes and as MOUSE if no. But unfortunately, when there are instances where the table inside the query does not contain field ABC, the report generates a error pop-up. Is there any way to by-pass this and run the report with other fields excluding the missing field?
I heard that IIF Exist function could help, but I am really blank here. I wrote the access query like below:
Iif (fieldExists(iif([ABC]=5, 'CAT', 'MOUSE'),iif([ABC]=5, 'CAT', 'MOUSE'), '')) AS TOMnJERRY
This function is maybe the shortest one to test if a field exists in Access:
Function FieldExists(ByVal Table As String, ByVal Field As String) As Boolean
On Error Resume Next
FieldExists = (DCount(Field, Table) >= 0)
End Function
How it works:
If the field exists, the expression (DCount(Field, Table) >= 0) is obviously always true, because DCount never returns a negative value. If the field doesn't exist, an error will occur and the program will jump to the next line without setting the return variable FieldExist, so this one will keep at default and this is false.
So the solution for your problem should look like this:
Iif (FieldExists('YourTable','ABC'), iif([ABC]=5, 'CAT', 'MOUSE'), '')
while inserting i can insert danish character in proper format in sqlite Db but while retrieving my query returns no result
String searchQuery= "SELECT * FROM article,product where article.ItemNo=product.ItemNo ";
if(searchText.length()>0)
{
searchQuery += " AND (article.itemNo like '"+ searchText +"%' OR product.Description like '"+ searchText +"%')";
}
in debug mode query is
`SELECT * FROM article,product where article.ItemNo=product.ItemNo AND (article.itemNo like '%ø%' OR product.Description like '%ø%')..`
No result returns
Proper query will be
SELECT * FROM article,product where article.ItemNo=product.ItemNo AND (article.itemNo like '%Ø%' OR product.Description like '%Ø%');
the desired description field value in Db is MØNTPUNG.
I am wondering is there any issue of case sensitivty?I am using UTF8 encoding for my raw file that will insert data to DB.
The documentation says:
SQLite only understands upper/lower case for ASCII characters by default. The LIKE operator is case sensitive by default for unicode characters that are beyond the ASCII range. For example, the expression 'a' LIKE 'A' is TRUE but 'æ' LIKE 'Æ' is FALSE.
To handle non-ASCII characters correctly, store an uppercase version of your string(s) in a separate column, and search in that with an uppercase search pattern.
I've created a table
Movie ( title varchar2(40), review XMLTYPE)
And review has: `
<review>
<reviewer>...</reviewer>
<title> ....</title>
<rating>.....</rating> </Review> </reviewer>
When I try to access :
SELECT X.reviewername FROM movie m, XMLTABLE ('for $d in /reviews/review
return $d'
PASSING OBJECT_VALUE
columns
reviewername VARCHAR2(50) PATH 'reviewer') AS X
I get an error at OBJECT_VALUE. Where am I going wrong?
EDIT: I changed the Query to
SELECT m.title,
warehouse2.*
FROM movie M,
XMLTABLE('/REVIEW'
PASSING m.reviews
COLUMNS
"Rail" varchar2(60) PATH '//RATING')
warehouse2;
But no rows are getting selected. Any suggestions?
Well for one thing, don't you have a typo: '/reviews/review ' ? there is no element called anywhere in your example.
Your XML isn't well formed, you have overlapping tags, you have mismatched reviews/Reviews (XML is case sensitive) and in your query you have reviews/review but your xml has /review (no s on the end). –
I'm getting a confusing select...where result, the table definition is:
CREATE TABLE modes (
key INTEGER,
mode INTEGER,
channel INTEGER,
name TEXT,
short_name TEXT,
def INTEGER,
highlight INTEGER,
catagory TEXT,
subcatagory TEXT);
It's populated with:
sqlite> select * from modes;
3|6|5|Green|G|0|255|a|b
3|6|6|Blue|B|0|255|a|b
3|9|1|Mode|Mode|0|255|a|b
3|9|2|Auto Mode Speed|Speed|0|255|a|b
3|9|3|Strobe|Strobe|0|255|a|b
3|9|4|Red|R|0|255|a|b
3|9|5|Green|G|0|255|a|b
3|9|6|Blue|B|0|255|a|b
3|9|7|Red2|R2|0|255|a|b
3|9|8|Green2|G2|0|255|a|b
3|9|9|Blue2|B2|0|255|a|b
3|6|4|Red|R|0|255|a|b
3|6|1|6|6|0|255|a|b
3|6|2|Auto mode speed|speed|0|255|a|b
3|6|3|Strobe|Strobe|0|255|strobe|b
Note the row 3rd from the bottom:
3|6|1|6|6|0|255|a|b
If I do a select:
SELECT * FROM modes where mode=6 and name="Mode" order by channel;
It returns:
3|6|1|6|6|0|255|a|b
Columns 4 and 5 (name and short_name) should not match, they are 6 and the match term is "Mode". If I change the match string "Mode" to any other string it works as expected. Is "Mode" a reserved word? or Did I somehow set a variable "Mode" to 6?. I don't understand this behavior.
If you use ["] it means columns, so when you do
name="Mode"
it means you search in column name that have same value as column Mode. So you select where mode=6 and name=6 actually on your code.
If you want to use string, use ['] not ["]
I try to use that code on my database..
select * from products
where name="Mode"
And I got error
ERROR: column "Mode" does not exist
LINE 2: where name="Mode"
I finally found it in the docs if anyone else is looking.
it's in the the sqlite3 FAQ
My familiarity is not with sqlite3, but I would say that it looks to me like you are doing name="Mode" which is taking the modes.mode object and checking it.
If you do SELECT * FROM modes where name="Mode" order by channel. You may find that it just gives you 3|6|1|6|6|0|255|a|b as well.