Team, question, Does PREPARE and EXECUTE triggers implicit commit?
Brother branchwise?
Can you elaborate this?
Is this what you need?
Can we use aggregate functions within group by?
but how?( –overwrite-tables didn’t help (
I don’t know this particular tool, possibly you use it wrong or you misunderstand the options.
re-check the manual.
I’m using docker image percona:5.7
Have the next problem, I’m dumping db’s correctly:
#!/bin/bash
for db in mysql aff_profits_test
do
time
mydumper
–host=127.0.0.1
–user=root
–password=pass
–outputdir=/home/ec2-user/full/$db
–rows=10000
-G -E -R
–compress
–build-empty-files
–threads=1
–verbose=3
–compress-protocol
–database=$db
done
Dumping proccess was successful and without any errors
Then I tried to restore mysql and aff_profits_test db’s for example:
#!/bin/bash
for db in mysql aff_profits_test
do
time
myloader
–host=127.0.0.1
–user=root
–password=pass
–directory=/home/ec2-user/full/$db
–threads=1
–verbose=3
–queries-per-transaction=100
–compress-protocol
–overwrite-tables
–database=$db
done
During restoring, I’m getting some errors:
** Message: 16:30:03.145: Thread 1 restoring `mysql`.`columns_priv` part 0
** Message: 16:30:03.145: Thread 1 restoring `mysql`.`db` part 0
** Message: 16:30:03.146: Thread 1 restoring `mysql`.`event` part 0
** Message: 16:30:03.146: Thread 1 restoring `mysql`.`func` part 0
** Message: 16:30:03.146: Thread 1 restoring `mysql`.`ndb_binlog_index` part 0
** Message: 16:30:03.146: Thread 1 restoring `mysql`.`proc` part 0
** (myloader:22186): CRITICAL **: 16:30:03.151: Error restoring mysql.proc from file mysql.proc.sql.gz: Table ‘mysql.proc’ doesn’t exist
Creating table `mysql`.`plugin`
** Message: 16:30:02.994: Dropping table or view (if exists) `mysql`.`proc`
** Message: 16:30:02.995: Creating table `mysql`.`proc`
** (myloader:22186): CRITICAL **: 16:30:02.996: Error restoring mysql.proc from file mysql.proc-schema.sql.gz: Invalid default value for ‘modified’
When restoring my own db, get the next errors:
Error restoring aff_profits_test.default_rate_shave_history from file aff_profits_test.default_rate_shave_history.sql.gz: Duplicate entry ‘1’ for key ‘PRIMARY’
** Message: 12:50:08.363: Thread 1 restoring `aff_profits_test`.`department_countries` part 0
** Message: 12:50:08.363: Thread 1 restoring `aff_profits_test`.`department_rate_tables` part 0
** Message: 12:50:08.363: Thread 1 restoring `aff_profits_test`.`department_rates` part 0
** Message: 12:50:08.364: Thread 1 restoring `aff_profits_test`.`department_site_alias` part 0
** Message: 12:50:08.364: Thread 1 restoring `aff_profits_test`.`department_sites` part 0
** Message: 12:50:08.364: Thread 1 restoring `aff_profits_test`.`details` part 0
* (myloader:3844): CRITICAL *: 12:50:08.426: Error restoring aff_profits_test.details from file aff_profits_test.details.sql.gz: Duplicate entry ’59eef12677075′ for key ‘PRIMARY’
** Message: 12:50:08.426: Thread 1 restoring `aff_profits_test`.`emails` part 0
* (myloader:3844): CRITICAL *: 12:50:08.447: Error restoring aff_profits_test.emails from file aff_profits_test.emails.sql.gz: Duplicate entry ‘1’ for key ‘PRIMARY’
** Message: 12:50:08.447: Thread 1 restoring `aff_profits_test`.`emails_parts` part 0
** Message: 12:50:08.447: Thread 1 restoring `aff_profits_test`.`errors` part 0
** Message: 12:50:08.447: Thread 1 restoring `aff_profits_test`.`faq_items` part 0
This is this param:
–overwrite-tables, -o
Drop any existing tables when restoring schemas
probably, you don’t restore schema.
Anyway, the param is NOT about erasing data, but about dropping tables.
Afaik, no.
and i want to find the maximum salary branch wise.
ps: Select salary from table_name group by dept having salary = max(salary);
ps: Select salary from table_name group by dept having salary = max(salary);
Brother branchwise?
no
ps: I wrote it wrong. Is this correct ->Select salary from table_name group by dept having salary = max(salary);
Kindly point out why, Too.
Kindly point out why, Too.
I think cuz having clause can only be used to filter out the group…so in this case max(salary) is an aggregate function which works on whole the group and we can’t extract salary of a single row alone… So max(salary) can only be compared with something else like..>10000 etc
ok sorry, i wrote it wrong, is this right then Select salary from table_name group by dept having salary = max(salary);
Why don’t you run this query and see the result?
I want to know the reason behind not working.
Oh man I have written the reason….when using group by clause you can only use column as a whole in having clause . a single row can’t be used….like u have used salary
Didn’t get the meaning of using column as a whole. Can you elaborate this?
yeah. So salary here means each particular row salary within a group. Am I wrong and the max(salary) means maximum within each group.
Ya
So, what’s wrong. Don’t they make sense?
Kindly point out why, Too.
No, you can’t aggregate a field and is it without aggregation at the same time in a quiery
and i want to find the maximum salary branch wise.
What at all should this mean,
“the maximum salary branch wise” ?
Kindly point out why, Too.
Select dept, max(salary) as max_salary
from table_name
group by dept
Is this what you need?
This is correct
The deep reason is you can’t write SQL queries, you sold learn it first.
Each field in a row is EITHER being aggregated OR used as group dimension. You cannot do both things at the same time. Either this or that.
mySQL actually allows this, but this is wrong to do so.
DEPT | SALARY
1 20
1 10
2 30
2 20
select dept,salary from … group by dept order by dept, salary DESC
and i want to find the maximum salary branch wise.
Select salary from table_name group by Salary having salary = max(salary);
Is this right? Kindly point out the mistake !!