I have a MariaDB SQL table, with two different ID rows. Id’s have been imported from a previous DB version (old_id reference is from another table), as a transitional measure searches need to be done to find id’s, with a preference for the older id value. Only ONE row can ever be returned . Table:…
Tag: mysql
Select sum if and having count
I have 3 tables table artist with artist_id, name; table album with album_id, artist_id, name; table songs with song_id, artist_id, album_id, (few more things but I don’t think they are necessary for this problem); I want to select a table with the name of the artist, number of albums with equal or more…
How to select only latest added records avoiding duplicates
I need to select from the table competition_rounds the latest added records which are linked to the competition_seasons table with the season_id column, eg: competition_rounds competition_seasons I want return only: the problem’s that my query return all rounds available: NB: The table competition simpl…
Will remove MySQL logs file impact the performance of the database?
One of our users is using Cloud SQL(MySQL). They turn on general logs flag and log_output is file. They need these general logs because of some special circumstances. MySQL generates about 8TB of general logs and these logs result a bigger use of the disk. Here is the tricky part: They want to remove these ge…
Iterate rows base on its entries column value
I need help on SQL SELECT QUERY. This is my TABLE. id | name | entries | ——————————— 1 | Jose Rizal | 1 | 2 | Raffy Tulfo | 2 | 3 | Cong …
how do i add up on sql so it doesn’t double because group by
when i’m running my program, the results of the number instead make a number merge and make the number into many results. the results is this enter image description here Answer Seems you are trying to get the sum() per po number. lets put this in a subquery then join again those tables you want info to…
Is there an elegant and efficient SQL way of listing all substring positions?
I have a text column in an sql database. My task is to find all occurrences of a given string in the texts, and list the character positions text by text (for backreference later in the application). …
Populate an HTML DropDown List with data from mysql database without PHP
I’m currently building a rails app where im trying to fetch data from different tables from my sql database and I need to put that fetched data (id, first_name, last_name) into an HTML Drop-down where …
write an sql query to look up the names of classes that meets in room R128
Consider the following schema: Student(snum, sname, major,level) Class(cname, meets-at,room, fid) Faculty(fid, fname, depname) Enrolled(snum, cname) write an SQL query to find the names of all the classes that don’t meet in room R128 with the smallest number of students(compared to all other classes). A…
Getting all rows with common value in column A and specific value in column B
In MySQL I have table matcher_table with columns matcher and type. Records which are put here can have many different values for type column. One type matches another one only when value for matcher …