This question already has answers here:
Query based on multiple where clauses in Firebase
(8 answers)
Closed 3 years ago.
From below query I get the data in order of timestamp
Query Users = FirebaseDatabase.getInstance.getReference.child("Users").orderbychild("timestamp");
Now all children are ordered by time.
But how do I filter this query by CurrentUserId?
Query CurrentUser = Users.orderbychild("CurrentUserId");
Firebase does not support multiple orderbychild method. What you can do is, first fetch records from Firebase with current user id
Query Users = FirebaseDatabase.getInstance.getReference.child("Users").orderbychild("CurrentUserId");
Then do timestamp sorting at client end.
Related
This question already has answers here:
It is possible to have a contains search query in firebase? [duplicate]
(2 answers)
Closed 3 years ago.
i want to search from firebase where the name contain that character from search box at any position in the name? any one help me please
just like this
Query firebaseSearchQuery =
myRef.orderByChild("from").contains(searchText);
You cannot perform contains query in firestore, you can only perform equals to query in firestore, if you want to perform contains query you need to integrate with Algolia
This question already has answers here:
Select random row from a sqlite table
(7 answers)
Closed 3 years ago.
I want to randomize some values using ID in sqlite query.
* am using quiz app and want to randomize our question. In database there is a column for category where category id is used to select proper cat and I want randomize only question with limit *
String query = "select * from quiz where id =" +id ;
SELECT *
Says to select all non-hidden columns from the table. The correct syntax for retrieving specific columns is to code the specific column names (or if there are potential ambiguities tablename.columnname e.g. quiz.question).
So you would want
SELECT question FROM quiz .....
To select a random question, assuming that question is the required column name, then you could use :-
String query = "SELECT question FROM quiz ORDER BY random();";
If you wanted to limit the number of rows returned you could use
String query = "SELECT question FROM quiz ORDER BY random() LIMIT 10;";
This question already has answers here:
Sorting dates in sqlite database?
(3 answers)
Closed 6 years ago.
I have stored date in sqlite database as text in this format : '1 Jan 99'.
Now I want to get data from sqlite database in order by date.
Already tried :
SELECT * FROM Table ORDER BY date(dateColumn) DESC
Select * from Table order by datetime(datetimeColumn) DESC
Please Help!!
try the requet SELECT * FROM Table ORDER BY dateColumn
This question already has answers here:
What is difference between setMaxResults and setFetchSize in org.hibernate.Query?
(3 answers)
Closed 7 years ago.
I have the below code and trying to limit the number of records retrieved. (LIMIT), but i always get all the rows. I see forums recommending me to use Query, but is not possible to achieve it using criteria ?
Criteria criteria = session.createCriteria(Application.class)
.add(Restrictions.gt("lastModifiedOn", applicationLastRunTime))
.add(Restrictions.eq("lead", false))
.addOrder(Order.asc("lastModifiedOn"));
criteria.setFetchSize(40);
criteria.list()
try to use:
public Criteria setMaxResults(int maxResults)
Set a limit upon the number of objects to be retrieved.
Parameters:
maxResults - the maximum number of results
Returns:
this (for method chaining)
Criteria criteria = session.createCriteria(Application.class)
.add(Restrictions.gt("lastModifiedOn", applicationLastRunTime))
.add(Restrictions.eq("lead", false))
.addOrder(Order.asc("lastModifiedOn"));
criteria.setMaxResults(40);
criteria.list()
more info: What is difference between setMaxResults and setFetchSize in org.hibernate.Query?
This question already has answers here:
Best way to avoid duplicate entry into mysql database
(4 answers)
Closed 7 years ago.
I parse a .lst file to get data, then I use hibernate in order to add these data in a mysql database.
My file is always updated with new data but it KEEPS existing ones.
The question is how can I avoid duplicates data in my database when I parse the file a scond time.
Thanks
INSERT INTO table_name ('your fields') VALUES ('New values') ON DUPLICATE KEY UPDATE field1=' value',field2='value',.....;
Table Structure:
make this 2 fields (name and city )Uniqe
ex:
INSERT INTO tbl_stud(name,city)values('Divyesh','Ahmedabad') ON DUPLICATE KEY UPDATE name='Divyesh',city='Ahmedabad';