World: r3wp
[SQLite] C library embeddable DB .
older newer | first last |
amacleod 17-Dec-2008 [805] | Let me first make sure i need fts... I want to find a sub-string within a larger string: for example: find the the rows that contain word "table" in a column called f_text one row of which might contain "When inserting into an fts table, if no docid is provided," This would be a hit since table is contained in the string. |
sqlab 18-Dec-2008 [806] | like is your friend |
amacleod 18-Dec-2008 [807] | syntax? |
Robert 18-Dec-2008 [808] | See SQLite homepage. It's something like this: LIKE '%...%' |
Chris 18-Dec-2008 [809] | Begins with is LIKE '...%' Anywhere is LIKE '%...%' End is LIKE '%...' Rebol filenames: LIKE '%.r' |
sqlab 18-Dec-2008 [810] | select * from table where f_text like '%table%' but the wildcards may vary according the database |
[unknown: 5] 18-Dec-2008 [811] | Amacleod - http://www.w3schools.com/sql/sql_like.asp |
amacleod 18-Dec-2008 [812] | Thanks, I try it out in the morning. I googled but could not find it. I've had trouble finding a good source of docs for sqlite before. w3schools looks good. Thanks again all! |
GiuseppeC 19-Dec-2008 [813x2] | Amacleod: if you search for ANSI 92 you should be able to find for the complete specification. |
This also brings me a question: what about SQLite and UNICODE ? | |
amacleod 21-Dec-2008 [815x4] | I got the 'like' command working with a text string but I can not fiqure out how to use variables... something like: rslts: sql reduce [{SELECT * FROM books WHERE ftext LIKE '%?%' } var] |
This works: rslts: sql reduce [{SELECT * FROM books WHERE ftext LIKE '%string%' } ] | |
SQL reduce [{INSERT INTO table VALUES (?, ?, ?)} fname lname phone] | |
Ignore that last message...Sorry | |
Graham 22-Dec-2008 [819] | you have to create your dialected string first |
sqlab 22-Dec-2008 [820] | A concatenation like like '%' || ? || '%' shoud work |
PeterWood 22-Dec-2008 [821] | I got this unexpected behaviour: >> do %~/Code/Library/Rebol/sqlite.r Script: "SQLite driver" (26-Nov-2008) >> connect %~/Code/SQLite3/mydata.db ** User Error: SQLite out of memory ** Near: make error! reform ["SQLite" error] >> change-dir %~/Code/SQLite3 == %/Users/peter/Code/SQLite3 / >> connect %mydata.db == 3400768 |
amacleod 22-Dec-2008 [822x7] | sqlab, reslts: sql reduce [{select * from fdbooks where ftext like '%'||?||'%'} srch] == [] where srch: "ladders" no error but not finding what should be there.: reslts: sql reduce [{select * from fdbooks where ftext like '%ladders%'}] == [[2 "FFP-LADDERS" "1-PORTABLE LADDERS" "2." " SIZES AND TYPES OF PORTABLE LADDERS IN USE^/" "" 4-Dec-2008/15:29:1 9] [4 "FFP-LADD... |
I got it! it works when srch: 'ladders | |
as word? | |
Not string? | |
What if I want multi-word string? as in; reslts: sql reduce [{select * from fdbooks where ftext like '%aluminum ladders%'}] == [[9 "FFP-LADDERS" "1-PORTABLE LADDERS" "3." " CONSTRUCTION OF PORTABLE ALUMINUM LADDERS^/" "" 4-Dec-2008/15:29:19 ] [10 "FFP-LADD... | |
and while we are here... what about multiple words in string... ladders and "aluminum" as apposed to "aluminum ladders" | |
And how could I figure this out myself. Is this syntax a part of the sqlite.r interface or sqlite itself? | |
Graham 22-Dec-2008 [829] | You need a primer in sql ... |
amacleod 22-Dec-2008 [830x2] | I can find the sql commands but I do not know how to rebolize them. Where can I find that I need to do this: '%'||?||'%' ? |
I do not see anything like that in any docs I can find. | |
Graham 22-Dec-2008 [832x4] | You construct your sql statement and test it. |
Then you substitute your variables ... that's it. | |
the sql statements are standard sql. You don't need to use the ? stuff .... ie. you can compose your statement before hand. | |
I don't know sqllite's syntax .. but this looks wrong to me reslts: sql reduce [{select * from fdbooks where ftext like '%aluminum ladders%'}] it should simply be reslts: sql {select * from fdbooks where ftext like '%aluminum ladders%'} | |
BrianH 22-Dec-2008 [836x2] | Those || are string concatenation, afaict. Use JOIN in REBOL for that. |
Or REJOIN. | |
Graham 22-Dec-2008 [838x4] | I've never tested whether the sql dialect can replace ? inside single quotes. |
Anyway, you don't need to use the sql dialect ... just create your sql statement and then execute it. | |
And once you learn sql, then you can look at the dialect .... which is a simple substitution thing. | |
Instead of LIKE, you can also use CONTAINS | |
BrianH 22-Dec-2008 [842] | SQLite has a CONTAINS extension? |
Graham 22-Dec-2008 [843] | oh ... sqlite ? ... ooops |
sqlab 22-Dec-2008 [844x2] | a || b is the sqlite syntax for concatenation of two strings. http://www.sqlite.org/lang_expr.html |
Dont't use the reduce | |
amacleod 22-Dec-2008 [846] | sqlab, >> reslts: sql reduce [{select * from fdbooks where ftext like '%aluminum%' || '%ladder%'}] == [[9 "FFP-LADDERS" "1-PORTABLE LADDERS" "3." " CONSTRUCTION OF PORTABLE ALUMINUM LADDERS^/" "" 4-Dec-2008/15:29:19 ] [10 "FFP-LADD... works. Thanks again...but |
BrianH 22-Dec-2008 [847] | Equivalent to the above: {select * from fdbooks where ftext like '%aluminum%ladder%'} |
amacleod 22-Dec-2008 [848] | How do I do that with variables? |
BrianH 22-Dec-2008 [849] | Are you checking for whether - Both of the words are in the string in that order - Both of the words are in the string directly adjacent to each other in that order - Both of the words are in the string in any order - Either of the words are in the string in any order ? |
amacleod 22-Dec-2008 [850] | It gives different results... >> reslts: sql [{select * from fdbooks where ftext like '%aluminum%' || '%ladder%'}] == [[9 "FFP-LADDERS" "1-PORTABLE LADDERS" "3." " CONSTRUCTION OF PORTABLE ALUMINUM LADDERS^/" "" 4-Dec-2008/15:29:19 ] [10 "FFP-LADD... >> reslts: sql [{select * from fdbooks where ftext like '%ladder%aluminum%' }] == [[11 "FFP-LADDERS" "1-PORTABLE LADDERS" "3.1.1" { Solid Beam Aluminum Construction- This type of ladder has a solid side rail co... |
BrianH 22-Dec-2008 [851x2] | Answer my question first then I can answer yours :) |
Pick one of the 4. | |
amacleod 22-Dec-2008 [853x2] | I need to search for multi-word string "aluminum ladder" (in that order... but also would like to beable to search for the occurnace of multiple words in any order: "aluminum" and "Ladder" and "water" etc |
2 and 3 I suppose | |
older newer | first last |