ANN: Code Factory for MySQL 13.9 released

2013-09-23 Thread SQL Maestro Team
Hi!

SQL Maestro Group announces the release of Code Factory for MySQL
13.9, a powerful Windows GUI solution for querying MySQL databases and
managing the data.
http://www.sqlmaestro.com/products/mysql/codefactory/

Please note that before Oct 13 you can purchase all our products and
bundles with up to 25% discount. Please find details at
http://www.sqlmaestro.com/purchase/

Top 10 new features:


 1. Improved SQL Editor.
 2. Updated SQL Dump wizard.
 3. Keyboard-interactive SSH authentication.
 4. New Start Page with quick access to recently connected databases.
 5. Data import from several files to a single table.
 6. Data export to the JSON format.
 7. Enhanced data grids.
 8. The Script Runner tool.
 9. Colored profiles in Database Explorer.
10. New modern progress windows.

Full press-release (with explaining screenshots) is available at:
http://www.sqlmaestro.com/news/company/codefactories_updated_to_13_9/

Background information:

SQL Maestro Group offers complete database admin and management tools
for MySQL, Oracle, MS SQL Server, DB2, PostgreSQL, SQL Anywhere,
SQLite, Firebird and MaxDB providing the highest performance,
scalability and reliability to meet the requirements of today's
database applications.

Sincerely yours,
The SQL Maestro Group Team
http://www.sqlmaestro.com

-- 
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:http://lists.mysql.com/mysql



Re: Problem with having

2013-09-23 Thread Sukhjinder K. Narula
Hi,

In your second query, you seem to have MIN(date_time), but you are talking
about maximum. So your group by query is actually pulling the minimum date
for this recipe.

Regards.

On Mon, Sep 23, 2013 at 3:35 PM, Larry Martell larry.mart...@gmail.comwrote:

 I want to find the rows from a table that have the max date_time for each
 recipe. I know I've done this before with group by and having, but I can't
 seem to get it to work now. I get the correct row id, but not the correct
 date_time. I'm sure I'm missing something simple.

 For purposes of showing an example, I'll use one recipe, 19166.


 For that recipe here's the row I would want:

 mysql select id, MAX(date_time) from data_cstmeta  where recipe_id =
 19166;
 +-+-+
 | id  | MAX(date_time)  |
 +-+-+
 | 1151701 | 2013-02-07 18:38:13 |
 +-+-+
 1 row in set (0.01 sec)

 I would think this query would give me that - it gives me the correct id,
 but not the correct date_time:

 mysql SELECT id, date_time as MaxDateTime  FROM data_cstmeta  where
 recipe_id = 19166 group by recipe_id HAVING MIN(date_time);
 +-+-+
 | id  | MaxDateTime |
 +-+-+
 | 1151701 | 2010-12-13 16:16:55 |
 +-+-+
 1 row in set (0.01 sec)

 How can I fix this?

 Thanks!
 -larry



Problem with having

2013-09-23 Thread Larry Martell
I want to find the rows from a table that have the max date_time for each
recipe. I know I've done this before with group by and having, but I can't
seem to get it to work now. I get the correct row id, but not the correct
date_time. I'm sure I'm missing something simple.

For purposes of showing an example, I'll use one recipe, 19166.


For that recipe here's the row I would want:

mysql select id, MAX(date_time) from data_cstmeta  where recipe_id = 19166;
+-+-+
| id  | MAX(date_time)  |
+-+-+
| 1151701 | 2013-02-07 18:38:13 |
+-+-+
1 row in set (0.01 sec)

I would think this query would give me that - it gives me the correct id,
but not the correct date_time:

mysql SELECT id, date_time as MaxDateTime  FROM data_cstmeta  where
recipe_id = 19166 group by recipe_id HAVING MIN(date_time);
+-+-+
| id  | MaxDateTime |
+-+-+
| 1151701 | 2010-12-13 16:16:55 |
+-+-+
1 row in set (0.01 sec)

How can I fix this?

Thanks!
-larry


Re: Problem with having

2013-09-23 Thread Larry Martell
On Mon, Sep 23, 2013 at 1:51 PM, Sukhjinder K. Narula
narula...@gmail.comwrote:

 Hi,

 In your second query, you seem to have MIN(date_time), but you are
 talking about maximum. So your group by query is actually pulling the
 minimum date for this recipe.


I pasted the wrong query in. I get the same results regardless of if I have
MIN or MAX - I get the id of the max, but the date_time of the min.



 On Mon, Sep 23, 2013 at 3:35 PM, Larry Martell larry.mart...@gmail.comwrote:

 I want to find the rows from a table that have the max date_time for each
 recipe. I know I've done this before with group by and having, but I can't
 seem to get it to work now. I get the correct row id, but not the correct
 date_time. I'm sure I'm missing something simple.

 For purposes of showing an example, I'll use one recipe, 19166.


 For that recipe here's the row I would want:

 mysql select id, MAX(date_time) from data_cstmeta  where recipe_id =
 19166;
 +-+-+
 | id  | MAX(date_time)  |
 +-+-+
 | 1151701 | 2013-02-07 18:38:13 |
 +-+-+
 1 row in set (0.01 sec)

 I would think this query would give me that - it gives me the correct id,
 but not the correct date_time:

 mysql SELECT id, date_time as MaxDateTime  FROM data_cstmeta  where
 recipe_id = 19166 group by recipe_id HAVING MIN(date_time);
 +-+-+
 | id  | MaxDateTime |
 +-+-+
 | 1151701 | 2010-12-13 16:16:55 |
 +-+-+
 1 row in set (0.01 sec)

 How can I fix this?

 Thanks!
 -larry





Re: Problem with having

2013-09-23 Thread shawn green

Hi Larry,

On 9/23/2013 3:58 PM, Larry Martell wrote:

On Mon, Sep 23, 2013 at 1:51 PM, Sukhjinder K. Narula
narula...@gmail.comwrote:


Hi,

In your second query, you seem to have MIN(date_time), but you are
talking about maximum. So your group by query is actually pulling the
minimum date for this recipe.



I pasted the wrong query in. I get the same results regardless of if I have
MIN or MAX - I get the id of the max, but the date_time of the min.




On Mon, Sep 23, 2013 at 3:35 PM, Larry Martell larry.mart...@gmail.comwrote:


I want to find the rows from a table that have the max date_time for each
recipe. I know I've done this before with group by and having, but I can't
seem to get it to work now. I get the correct row id, but not the correct
date_time. I'm sure I'm missing something simple.

For purposes of showing an example, I'll use one recipe, 19166.


For that recipe here's the row I would want:

mysql select id, MAX(date_time) from data_cstmeta  where recipe_id =
19166;
+-+-+
| id  | MAX(date_time)  |
+-+-+
| 1151701 | 2013-02-07 18:38:13 |
+-+-+
1 row in set (0.01 sec)

I would think this query would give me that - it gives me the correct id,
but not the correct date_time:

mysql SELECT id, date_time as MaxDateTime  FROM data_cstmeta  where
recipe_id = 19166 group by recipe_id HAVING MIN(date_time);
+-+-+
| id  | MaxDateTime |
+-+-+
| 1151701 | 2010-12-13 16:16:55 |
+-+-+
1 row in set (0.01 sec)

How can I fix this?

Thanks!
-larry



You have to do a two-stage match. One stage to find the MAX() of a value 
for each recipe_id, the other to match that MAX() to one or more rows to 
give you the best ID values.


Here's a subquery method of doing it.  There are many many others 
(google for groupwize maximum)


SELECT a.id, b.MaxDateTime
FROM data_cstmeta a
INNER JOIN (
SELECT MAX(date_time) MaxDateTime
FROM data_cstmeta
WHERE recipe_id = 19166
) b
  on b.MaxDateTime = a.date_time
WHERE recipe_id = 19166;

Yours,
--
Shawn Green
MySQL Principal Technical Support Engineer
Oracle USA, Inc. - Hardware and Software, Engineered to Work Together.
Office: Blountville, TN

--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:http://lists.mysql.com/mysql



Re: Problem with having

2013-09-23 Thread Ananda Kumar
select recipe_id,max(maxdatetime) from data_csmeta group by recipe_id
having recipe_id=19166;


On Mon, Sep 23, 2013 at 4:15 PM, shawn green shawn.l.gr...@oracle.comwrote:

 Hi Larry,


 On 9/23/2013 3:58 PM, Larry Martell wrote:

 On Mon, Sep 23, 2013 at 1:51 PM, Sukhjinder K. Narula
 narula...@gmail.comwrote:

  Hi,

 In your second query, you seem to have MIN(date_time), but you are
 talking about maximum. So your group by query is actually pulling the
 minimum date for this recipe.


 I pasted the wrong query in. I get the same results regardless of if I
 have
 MIN or MAX - I get the id of the max, but the date_time of the min.



  On Mon, Sep 23, 2013 at 3:35 PM, Larry Martell larry.mart...@gmail.com
 **wrote:

  I want to find the rows from a table that have the max date_time for
 each
 recipe. I know I've done this before with group by and having, but I
 can't
 seem to get it to work now. I get the correct row id, but not the
 correct
 date_time. I'm sure I'm missing something simple.

 For purposes of showing an example, I'll use one recipe, 19166.


 For that recipe here's the row I would want:

 mysql select id, MAX(date_time) from data_cstmeta  where recipe_id =
 19166;
 +-+---**--+
 | id  | MAX(date_time)  |
 +-+---**--+
 | 1151701 | 2013-02-07 18:38:13 |
 +-+---**--+
 1 row in set (0.01 sec)

 I would think this query would give me that - it gives me the correct
 id,
 but not the correct date_time:

 mysql SELECT id, date_time as MaxDateTime  FROM data_cstmeta  where
 recipe_id = 19166 group by recipe_id HAVING MIN(date_time);
 +-+---**--+
 | id  | MaxDateTime |
 +-+---**--+
 | 1151701 | 2010-12-13 16:16:55 |
 +-+---**--+
 1 row in set (0.01 sec)

 How can I fix this?

 Thanks!
 -larry


 You have to do a two-stage match. One stage to find the MAX() of a value
 for each recipe_id, the other to match that MAX() to one or more rows to
 give you the best ID values.

 Here's a subquery method of doing it.  There are many many others (google
 for groupwize maximum)

 SELECT a.id, b.MaxDateTime
 FROM data_cstmeta a
 INNER JOIN (
 SELECT MAX(date_time) MaxDateTime
 FROM data_cstmeta
 WHERE recipe_id = 19166
 ) b
   on b.MaxDateTime = a.date_time
 WHERE recipe_id = 19166;

 Yours,
 --
 Shawn Green
 MySQL Principal Technical Support Engineer
 Oracle USA, Inc. - Hardware and Software, Engineered to Work Together.
 Office: Blountville, TN

 --
 MySQL General Mailing List
 For list archives: http://lists.mysql.com/mysql
 To unsubscribe:http://lists.mysql.com/mysql




pt-table-checksum: --ignore-tables-regex does not work properly?

2013-09-23 Thread RafaƂ Radecki
Hi All.

I use:
percona-toolkit-2.2.4-1.noarch
Percona-Server-server-55-5.5.28-rel29.1.335.rhel6.x86_64
Percona-Server-shared-compat-5.5.28-rel29.1.335.rhel6.x86_64
Percona-Server-client-55-5.5.28-rel29.1.335.rhel6.x86_64
Percona-Server-shared-55-5.5.28-rel29.1.335.rhel6.x86_64
on
Centos 6.3 2.6.32-279.14.1.el6.x86_64

I have created checksum table and tried to use --ignore-tables-regex to
remove some tables from checking.

pt-table-checksum --chunk-size-limit= --nocheck-plan --replicate-check
--ignore-tables-regex=^test.s_.*_tmp$
--ignore-tables=test.catalogsearch_fulltext,test.catalogsearch_result,test.report_event,test.report_viewed_product_index,test.z_crawler_log,test.z_logger_debug_ajax,test.z_crawler_queue,test.catalog_category_anc_categs_index_tmp,test.catalog_category_anc_products_index_tmp,test.catalog_category_product_index_enbl_tmp,test.catalog_category_product_index_tmp,test.catalog_product_index_eav_decimal_tmp,test.catalog_product_index_eav_tmp,test.catalog_product_index_price_bundle_opt_tmp,test.catalog_product_index_price_bundle_sel_tmp,test.catalog_product_index_price_bundle_tmp,test.catalog_product_index_price_cfg_opt_agr_tmp,test.catalog_product_index_price_cfg_opt_tmp,test.catalog_product_index_price_downlod_tmp,test.catalog_product_index_price_final_tmp,test.catalog_product_index_price_opt_agr_tmp,test.catalog_product_index_price_opt_tmp,test.catalog_product_index_price_tmp,test.cataloginventory_stock_status_tmp,test.z_I04_data_for_crawler,test.z_import_prices_mdk,test.z_import_prices_sku,test.z_import_translations,test.z_import_translations_model
--recursion-method dsn=h=localhost,D=percona,t=dsns --user=percona
--password=percona --nocheck-replication-filters --databases=test,mysql
localhost

But it does not work, for example table test.s_xxx_tmp gives error message:

09-18T03:10:47 Skipping table test.s_xxx_tmp because it has problems on
these replicas:
Table test.s_xxx_tmp does not exist on replica server.local
This can break replication.  If you understand the risks, specify
--no-check-slave-tables to disable this check.
09-18T03:10:47 Error checksumming table test.s_xxx_tmp: DBD::mysql::db
selectrow_hashref failed: Tab
le 'test.s_xxx_tmp' doesn't exist [for Statement EXPLAIN SELECT * FROM
`test`.`s_xxx_tmp` WHERE 1=1] at /usr/bin/pt-table-checksum line 6528.

I've tried --ignore-tables-regex= multiple times:
^test.s_.*_tmp$
'^test.s_.*_tmp$'
^test.s_.\*_tmp$
^test.s_\.\*_tmp$
but without good result. What is the correct syntax in this case?

Best regards,
Rafal Radecki.


Re: Problem with having

2013-09-23 Thread Larry Martell
On Mon, Sep 23, 2013 at 3:15 PM, shawn green shawn.l.gr...@oracle.comwrote:

 Hi Larry,


 On 9/23/2013 3:58 PM, Larry Martell wrote:

 On Mon, Sep 23, 2013 at 1:51 PM, Sukhjinder K. Narula
 narula...@gmail.comwrote:

  Hi,

 In your second query, you seem to have MIN(date_time), but you are
 talking about maximum. So your group by query is actually pulling the
 minimum date for this recipe.


 I pasted the wrong query in. I get the same results regardless of if I
 have
 MIN or MAX - I get the id of the max, but the date_time of the min.



  On Mon, Sep 23, 2013 at 3:35 PM, Larry Martell larry.mart...@gmail.com
 **wrote:

  I want to find the rows from a table that have the max date_time for
 each
 recipe. I know I've done this before with group by and having, but I
 can't
 seem to get it to work now. I get the correct row id, but not the
 correct
 date_time. I'm sure I'm missing something simple.

 For purposes of showing an example, I'll use one recipe, 19166.


 For that recipe here's the row I would want:

 mysql select id, MAX(date_time) from data_cstmeta  where recipe_id =
 19166;
 +-+---**--+
 | id  | MAX(date_time)  |
 +-+---**--+
 | 1151701 | 2013-02-07 18:38:13 |
 +-+---**--+
 1 row in set (0.01 sec)

 I would think this query would give me that - it gives me the correct
 id,
 but not the correct date_time:

 mysql SELECT id, date_time as MaxDateTime  FROM data_cstmeta  where
 recipe_id = 19166 group by recipe_id HAVING MIN(date_time);
 +-+---**--+
 | id  | MaxDateTime |
 +-+---**--+
 | 1151701 | 2010-12-13 16:16:55 |
 +-+---**--+
 1 row in set (0.01 sec)

 How can I fix this?

 Thanks!
 -larry


 You have to do a two-stage match. One stage to find the MAX() of a value
 for each recipe_id, the other to match that MAX() to one or more rows to
 give you the best ID values.

 Here's a subquery method of doing it.  There are many many others (google
 for groupwize maximum)

 SELECT a.id, b.MaxDateTime
 FROM data_cstmeta a
 INNER JOIN (
 SELECT MAX(date_time) MaxDateTime
 FROM data_cstmeta
 WHERE recipe_id = 19166
 ) b
   on b.MaxDateTime = a.date_time
 WHERE recipe_id = 19166;


Having the recipe_id in the query was just to show an example. I really
want the id's with the max date for each recipe_id:

This is what I changed it to, which works, but is too slow. I need to find
a more efficient solution:

SELECT d1.id, d1.date_time as MaxDateTime
   FROM data_cstmeta d1
   LEFT JOIN data_cstmeta d2 ON d1.recipe_id = d2.recipe_id AND
d1.date_time  d2.date_time
   WHERE d2.recipe_id IS NULL


Re: Problem with having

2013-09-23 Thread Larry Martell
On Mon, Sep 23, 2013 at 2:17 PM, Sukhjinder K. Narula
narula...@gmail.comwrote:

 Hi,

 I see that. So the query seems to be picking the first entry out of the
 after grouping by a field and displaying it. And it seems to make sense
 since Having clause seems incomplete. I believe we need to complete the
 condition by HAVING MIN(date_time) ,  or = something.


After reading this, I see what the problem is:

http://dev.mysql.com/doc/refman/5.0/en/group-by-extensions.html

Then I read this:

http://dev.mysql.com/doc/refman/5.0/en/example-maximum-column-group-row.html

and changed it to this:

SELECT d1.id, d1.date_time as MaxDateTime
   FROM data_cstmeta d1
   LEFT JOIN data_cstmeta d2 ON d1.recipe_id = d2.recipe_id AND
d1.date_time  d2.date_time
   WHERE d2.recipe_id IS NULL

Which works, but is painfully slow. For a table with 200k rows it's been
running for 25 minutes and isn't done yet. That will be unacceptable to my
users.


 On Mon, Sep 23, 2013 at 3:58 PM, Larry Martell larry.mart...@gmail.comwrote:

 On Mon, Sep 23, 2013 at 1:51 PM, Sukhjinder K. Narula 
 narula...@gmail.com wrote:

 Hi,

 In your second query, you seem to have MIN(date_time), but you are
 talking about maximum. So your group by query is actually pulling the
 minimum date for this recipe.


 I pasted the wrong query in. I get the same results regardless of if I
 have MIN or MAX - I get the id of the max, but the date_time of the min.



 On Mon, Sep 23, 2013 at 3:35 PM, Larry Martell 
 larry.mart...@gmail.comwrote:

 I want to find the rows from a table that have the max date_time for
 each
 recipe. I know I've done this before with group by and having, but I
 can't
 seem to get it to work now. I get the correct row id, but not the
 correct
 date_time. I'm sure I'm missing something simple.

 For purposes of showing an example, I'll use one recipe, 19166.


 For that recipe here's the row I would want:

 mysql select id, MAX(date_time) from data_cstmeta  where recipe_id =
 19166;
 +-+-+
 | id  | MAX(date_time)  |
 +-+-+
 | 1151701 | 2013-02-07 18:38:13 |
 +-+-+
 1 row in set (0.01 sec)

 I would think this query would give me that - it gives me the correct
 id,
 but not the correct date_time:

 mysql SELECT id, date_time as MaxDateTime  FROM data_cstmeta  where
 recipe_id = 19166 group by recipe_id HAVING MIN(date_time);
 +-+-+
 | id  | MaxDateTime |
 +-+-+
 | 1151701 | 2010-12-13 16:16:55 |
 +-+-+
 1 row in set (0.01 sec)

 How can I fix this?

 Thanks!
 -larry







grouping and limiting results and rand()

2013-09-23 Thread Jeremiah Jester
Hello,

How would i go about selecting 5
random cars that are flagged as internet_special (value 1) for each
dealer from a specific table?  Ive tried sub selects with no luck.
Here's a basic query that has my
required conditional. Note that I get all unique dealers by doing a
distinct(dealer_web_name). Make sense? Using mysql 5.

select dealer_web_name,id,internet_special,active from inventory where
internet_special=1 and active=1;

Appreciate the help


Jj

-- 
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:http://lists.mysql.com/mysql



Re: grouping and limiting results and rand()

2013-09-23 Thread Peter Brawley

On 2013-09-23 8:10 PM, Jeremiah Jester wrote:

Hello,

How would i go about selecting 5
random cars that are flagged as internet_special (value 1) for each
dealer from a specific table?  Ive tried sub selects with no luck.
Here's a basic query that has my
required conditional. Note that I get all unique dealers by doing a
distinct(dealer_web_name). Make sense? Using mysql 5.

select dealer_web_name,id,internet_special,active from inventory where
internet_special=1 and active=1;

Appreciate the help


For ideas see Within-group quotas at 
http://www.artfulsoftware.com/infotree/queries.php.


PB

-

--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:http://lists.mysql.com/mysql