How do i do a like statement in ejb-ql? [duplicate] - ejb

This question already has answers here:
Closed 10 years ago.
Possible Duplicate:
Parameter in like clause JPQL
I got this code from an example, how do i do a search with ebj ql?
SELECT OBJECT(p)
FROM Person p
WHERE (p.name LIKE ?1)
How do i continue from here? I would like to return results where p.name contains string "test"

i found the solution. here is an example.
Query query = em.createQuery("SELECT c FROM TestEntity c WHERE c.titleLIKE :searchString");
query.setParameter("searchString", "%" + "test" + "%");

Related

SQLite unsure about ALL syntax [duplicate]

This question already has answers here:
SQLite syntax for "ALL"
(3 answers)
Closed last month.
I'm trying to find out which customer spent the most on orders, in addition to how much they have spent in total.
This is my current code. However, im getting a syntax error near ALL
SELECT c.id, sum(i.Quantity * p.UnitPrice) AS TotalSpend
FROM Customers c, Orders o, OrderItems i, Products p
WHERE c.id = o.CustomerID
AND o.id = i.OrderID
AND i.ProductID = p.id
AND sum(i.Quantity * p.UnitPrice) > ALL(
SELECT sum(i.Quantity * p.UnitPrice)
FROM OrderItems i, Products p
WHERE i.ProductID = p.id)
Not too sure where i have committed the syntax error
Apparently the keyword ALL is not supported by SQLite.

Trying to find a word in a string full text search sqlite

Hi I have a string which is a question for example: Where is the van ?
I have enabled Full Text search on sqlite
I have tried this:
String sql = "Select * from tblzh20 WHERE tblzh20 MATCH '" + question + "'";
however nothing is returned unless I just put van as the question!
I'm trying to search the table for keywords within the question and find the results? I'm sure this is possible but not sure how.
"Select * from tblzh20 WHERE tblzh20 MATCH '{keyword objective}:" + question + "'";

Get column count using Sqlite [duplicate]

This question already has answers here:
How to count number of columns in a table in SQLITE?
(5 answers)
Closed 8 years ago.
How can I get column count in table using Sqlite. I tried with SELECT count(*) FROM information_schema.COLUMNSC WHERE table_name = 'test' AND TABLE_SCHEMA = "test" it works fine for sql but doesnt works for Sqlite. Is there any other way for getting column count. Thank you..!
Try pragma table_info(table_name); which will give all the columns information-name,type etc. Refer http://www.sqlite.org/pragma.html
I tried without using pragma and it worked to get column count from table in Sqlite following is the code
ResultSet rs = stmt.executeQuery("SELECT * FROM TABLE");
ResultSetMetaData rsmd = rs.getMetaData();
int numberOfColumns = rsmd.getColumnCount();
System.out.println(numberOfColumns);

How to make thw query by LIKE not case sensitive? [duplicate]

This question already has answers here:
How to ignore accent in SQLite query (Android)
(4 answers)
Closed 8 years ago.
I have a query to seek data from SQLite for SEARCH realization in java project. I need that both variant with upper and lower first letters were true while making the query from SQLite. The query I make is such:
String sqlQuery1 = "SELECT * FROM city AS t1, region AS t2 ON t1.region_number = t2._id WHERE t1.name LIKE '%' || ? || '%';";
Then I put it in the next method:
public Cursor fetchRecordsByQuery(String query) {
return myDataBase.rawQuery(sqlQuery1, new String[] {query});
}
I need that the query was not case sensetive. That both results with lower case and upper case first buttons were true. How to make it? one thing - the symbols are russian.
If I understand it right, then you could do something like lower(t1.name) LIKE (something in lower case)

What is the meaning of the symbol "#" Before A String Literal? [duplicate]

This question already has answers here:
What's the # in front of a string in C#?
(9 answers)
Closed 9 years ago.
What is the concept # Before coming to select this code?
SqlDataSource2.SelectCommand = #"SELECT tblstore.storname,tblproduct.pid, tblproduct.pname, tblproduct.pprice, tblproduct.publisher, tblproduct.writer FROM tblproduct INNER JOIN tblstore ON tblproduct.storeid = tblstore.storeid WHERE tblproduct.pname LIKE #likeText";
SqlDataSource2.SelectParameters.Add("likeText", "%" + txtName.Text + "%");
that defines a string literal
string (C# Reference)
to quote msdn
"The advantage of verbatim strings is that escape sequences are not processed, which makes it easy to write, for example, a fully qualified file name"

Resources