Select the same columns from a list of tables

I am looking to run this query on a list of tables. SELECT Description,Code,count(*) as count FROM table1 group by Description,code having count(*) > 1 I will have to run this query on 30+ different tables, I was wondering If I could change the from

MySQL - Get items that do not match another table

I have two tables (table1 and table2) table1 has two columns day and timeSlot. table2 also has day and timeSlot columns. table1 has rows of date and times, table2 has rows of with inserted data including a date and time. My question is I am trying to

Search PHP / MySQL / PDO from the database

Trying to make a little Search feature for a user, so he can type in a date on a webpage made with HTML/PHP, and see which people in the db have registered as member on or after (a date). My user inputs the date in format 2015-10-01. This gets sent t

error # 1452 - assign FK twice for the same PK

I got this error - #1452 - Cannot add or update a child row: a foreign key constraint fails. I guess is I try to assign multiple foreign key to a primary key, or it is not? my table look like this user ===== uId (PK) friend ====== uId (FK of user.uId

REPLACE a string in MySQL but only a specified part

i would like to replace string in my query but only on the end of the string this is my example: SET @exampleString = 'example_a_chapter_a'; SELECT REPLACE(@exampleString ,'_a','_b1'); Result what I get is this: example_b1_chapter_b1 But i would like

Invert LIKE% & hellip;% possible?

In short I want to match a dictionary entry to a row of text, but it doesn't have to match the whole row, just the beginning. So it's in effect a sort of reverse LIKE %...% For example, SELECT * FROM `dictionary` WHERE (`simplified` = '铅笔的历史非常悠久,它起源于

Get the sum by comparing two tables

I have to tables ProdBiscuit As tb and StockData As sd , I have to get the sum of the quantity in StockData (quantite) with the condition of if (sd.status>0 AND sd.prodid = tb.id AND sd.matcuisine = 3) Here is my sql query SELECT tb.id, tb.nom, tb.pr

MySQL: returns the random value of each column

Note: This might be a strange question. I have a table containing first name and last name, which schema as follow (table name: random_names): id INT PRIMARY, AUTO INCREMENT first_name VARCHAR(100) NOT NULL last_name VARCHAR(100) NOT NULL I would lik

Select a random entry using two columns

I created a contest where people who refer others increase their odds of winning with each referral. Now I have to figure out how to use mysql or php to actually give them better odds. Selecting a random row won't cut it. In my table I have two colum

mysql concat_ws without duplicates

I am trying to concatenate a few fields into a single one, but only keep unique values in the resulting string. Example: title_orig | title_fr | title_de | title_it --------------------------------------------------------------------- KANDAHAR | KAND

MySQL Workbench charset

Does there exist any way to change the MySQL Workbench charset? My schema uses UTF-8 and when I view the table data (saved as UTF-8) or add data manually, it appears with charset errors, probably MySQL Workbench uses LATIN1.I think OP was asking abou

Fatal PDO PDO error

I have the following query: $sql = "UPDATE db.users SET $str WHERE users.{$this->row} = {$this->value} LIMIT 1"; Which echo's out: UPDATE db.users SET username=testUser, gid=3 WHERE users.username = mmiller LIMIT 1 However when I do: $coun

PHP PDO Update Statement Problem Statement

Hi everyone I've been trying my hand at PDO recently, and am currently trying to write a basic database class for a project i'm working on. However i have ran into problems trying to write a function for carrying out an update query using prepared st

mysqldump from recent records

Does mysqldump (or some other command) have an option to dump ONLY recently updated rows? I haven't been able to find anything in the docs about this. thx.You can give mysqldump a where clause using the --where option. So if you have a column called

The PHP query inserts 2 rows into the table

OK, here is the deal. I have 3 queries putting data in different tables. 2 of them are in included files. I've tried to put them into the main code, the result was the same. The first two queries inserts one row with the data and a blank row. The thi

SQL SUM of distinct lines and hellip; I am stuck!

Been trying to put together an SQL query that sorts data into financial years (which I've sorted) and then SUMs it according to each distinct value in the claim_id column table structure is: claim(id, claim_id, date, amount) SQL so far is: SELECT CAS

Mysqld crashes immediately running on Windows 7 & hellip;

I am trying to run MySql 5.1 on Windows 7 Home Premium 64 bit. I have downloaded the MSI installer from the MYSql website and installed it. The installation is successful, but the service does not start. If I try to run MySql manually using the mysql