I want to select max auto_no from the following varchar type column in my codeigniter model +————+ | auto_no | +————+ | 2020-00821 | | 2020-00822 | | 2020-00823 | | 2020-00824 | | …
Tag: mysql
Is there a way to count all the trailing zeros in a column in MySQL?
I am looking to find out if there is a way to count the number of trailing zeros in a column. The column is made up of a maximum of 13 numbers as shown below and I want to count all the zeros before …
MySQL SELECT only rows where tbl_col equal to this and that
I am struggling a bit with my SQL query. This is the query i have now, and it works as is, but i want to add some more to it. In the mysql table, there is a column that is named “type”. I want to filter the rows and get the rows with the string “sms” or the string “email”
how to display data on 2 different date ranges
I have the following date data, which is used to display MySQL data parameters and I have the following query: The result I want is that the program will display data from date :$tgaw to date: $tgak Answer You should be using prepared statements here, and also use the MySQL functions to add one month to the u…
How to Count Times an ID Appears in a Column in a Different Table
Apologies in advance: I’m sure this is relatively easy and has been asked ad nauseam, but I just can’t quite come up with the proper search. Basically, I’m trying to take a list of IDs queryed from …
How to use join to link values from one table to another
I have two tables. drivers name number email requests id driverassigned …. I want to get everything from drivers table that may or may not be mentioned in requests.driverassigned. I have tried using join but it returns rows that have a match. Here is what I have so far. I am sure there is a common solut…
Query for students passed or not passed in specific Subjects [closed]
I have a Table with Column Headings: ID Student_Name Roll_Number Subject1MarksObtained Subject1TotalMarks Subject2MarksObtained Subject2TotalMarks Subject3MarksObtained Subject3TotalMarks …
DATEDIFF vs (w1.date = w2.date +1) difference? MySQL syntax
I was working on a SQL database question using MySQL. The goal is to find all IDs that satisfy today is warmer than yesterday. I’ll show you my original code, which passed 2 out of 3 test cases and then a revised code which satisfies all 3. What is the functional difference between these two? Is it a My…
How to create group by age employee in php myqsl
I want to create chart.js for avarage age in my company. But I can’t create the query. SELECT DATEDIFF(CURRENT_DATE, STR_TO_DATE(t.employee_birthday, ‘%Y-%m-%d’))/365 AS `ageInYears` FROM `employee` …
MySql Query to get certain number of values from limit and order by rand()
In below SQL query I need 25 rows containing product = ‘y’ and 25 rows having product = ‘n’. Product is a column having Y/N value only. In limit of random 50 rows I need 25 rows from each values. Kindly assist. I have tried Union but it didn’t work. Answer Simply use UNION for ea…