Problem description: Finding online status of therapist users based on last interaction in Session table. Cannot keep last interaction date on User table but it should be separated on Session table. …
Tag: sql
Laravel add calculate the sum where the value is in another table
Basically i have two tables. answers and choices . In my choices table, I got a column choices.value which is has values 0-4. My current query like this $answers = DB::table(‘answers’) …
Dynamic value in sql query using php
I want to search a certain string in all the columns of different tables, so I am looping the query through every column name. but if i give it as dynamic value it does not seem to work. what is wrong?…
Queries in multiple loop and Ordering by id of last query
I have two while loops and two queries in the loops. I must order posts as DESC by its IDs. But posts loop is under another query’s loop. $follows=$db->prepare(“SELECT * FROM follows WHERE …
PHP, SQL-Query with IN clause troubleshooting
I have some problem with my Code, i tried to solve it on my own but i didnt found any matching solves. So i have an array with User_ids… var_dump($arr) array(6) { [0]=> int(5) [1]=> int(6) […
mysqli_fetch_assoc() expects parameter 1 to be mysqli_result, string given in while-loop
I currently have this code but it gives me the error mysqli_fetch_assoc() expects parameter 1 to be mysqli_result, string given on line 22 The code is this: 1 $servername = “localhost”; 2 $…
sql query selecting birthday today from number format
Let say i have identification card number in this format we can convert the number to birthday by using this code how do i select all user that is having birthday today ? is this possible ? Answer What I understand is first 6 digits of your ic is YYMMDD. If this is not the case please ignore. Accordingly you
MySQL syntax for summing several count data
I have a MySQL table called things_they_own with two columns: person and thing and my primary key is the combination of the two. Thus, there are several rows where the first column is a certain …
Cannot use object of type IlluminateDatabaseQueryBuilder as array
I cannot find the error here how do i fix this? $db2 = DB::connection(‘sqlsrv’)->table(‘Checkinout’) ->join(‘Z_MemRecord’,’Checkinout.Userid’,’=’,’Z_MemRecord.uid’) ->select(DB::raw(“…
Return all rows from an array
I’m trying to return a comma separated list of location names from a database. So far I have the SQL statement that I know works because it returns the correct results when tested in phpMyAdmin. I’m …