mysql

Can I change MySQL decimal precision on the fly?

I'm in need of allowing larger numbers in my Rails application. Is it safe to just change the decimal column from :precision => 10, :scale => 4 to :precision => 11, :scale => 4 without any interference on the existing data? ...

Solr returns 'oldest' records instead of 'newest'; 'Rows' and 'Start' parameters

How come Solr returns the "Oldest" records first when specifying these parameters. As you probably know these are mainly for "paging" purposes. And if I chose something like 10 Rows per page, and with the start set to 0, this means in my mind that the latest 10 records should be displayed. However, Solr displays the oldest 10 records. ...

CREATE TABLE new_table_name LIKE old_table_name with old_table_name's AUTO_INCREMENT values

Hello! Can I create a new table with an old table's autoincriment status in mysql client? I think, that ALTER TABLE new_table_name AUTO_INCREMENT=@my_autoincr_iment helps me, but this construction must use with a constant value. I don't wanna use a difficult script. Drochite na carmu! ...

MySql 'Select' help

I have some tables. These tables all have one column in common called 'classified_id': main_table: cars_table: id (PK) => 4222 id (PK) => 1021 classified_id => 25 classified_id => 25 Now, I want whenever a search is performed, to compare if any of the main_table.classified_id mat...

Mysql foreign key by non unique key -- how is that possible?

I was migrating mysql database to postgres and stumbled across the following block in DDL (Note: This is what I got from mysqldump): CREATE TABLE `catalog_property_value` ( `id` int(10) unsigned NOT NULL, `property_id` int(10) unsigned NOT NULL, `sort` int(10) unsigned NOT NULL, `value_number` decimal(15,5) DEFAULT NULL, `valu...

Symfony sfDoctrinePager with multiple tables

I was wondering how to get this to run. In my application I have a Category table and Product table. I need to have a pager which combines both Categories and Products for display in one list (first categories then products). Is there a way to get this going ? I tried left joining in the pager's query, but doesn't seem to do the trick. ...

Restore mysql lost table

I accidentally deleted a table in my mysql database. After that I've restored this table from backup which is scheduled daily at 00:01. But there are lost data from 00:01 to 12:34. Is there a way to restore these records? Table engine is myisam. ...

Mysql DB Table Rows Disappearing

Hello, A really weird (for me) problem is occurring lately. In an application that accepts user submitted data the following occurs at random: Rows from the Database Table where the user submitted data is stored are disappearing. Please note that there is NO DELETE, DROP, TRUNCATE or other SQL statement issued on the database table ex...

how B-tree indexing works in mysql

my question is , when I create an index for a table in mysql, I see that the index_type is type BTREE . Now although I understand about btree(s), I do not quiet understand how it stores the index and how the database searches the records based on this. I mean, btree is excellent for databases to perform read and writes large blocks of d...

mysql GROUP BY return the first record

Hi i far as i know mysql GROUP BY grouping to the last find record. Is there any solution to GROUP BY the first record I have setup the ORDER in SQL command and i need GROUP BY return the first record and not the last EDIT Here is the Query SELECT DISTINCT(master.masterID), langData.*, master.* FROM master_table as master ...

Postgresql Current timestamp on Update

What is the postgres equivalent of the below mysql code CREATE TABLE t1 ( created TIMESTAMP DEFAULT CURRENT_TIMESTAMP, modified TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP ); CREATE TABLE t2 ( created TIMESTAMP DEFAULT CURRENT_TIMESTAMP, modified TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP...

mysql: find highest average score

Hi, I've written a query that pulls out the average score per player who was in inning 4: SELECT batsmen.player_id, AVG(score) FROM batsmen WHERE batsmen.inning_no=4 GROUP BY player_id; But now I need to find the highest average score. obviously i could look at the output, orderby and easily see the highest average, but i would lik...

Web Payment Idea for mysql 3.23 and asp.net

My company has an old windows program. Written in turbo delphi mysql-max-3.23.53-win with zeos components. We need an web payment system integration for this. I have tried with visual studio 2008 and mysql connector, but the connector gives error to connect this database. we can not upgrade the mysql version because there is a lot of cod...

SQL request with "Group by" and "max" and "join" ?

Here is a sample of my DATA: CLIENT_ATTRIBUT : ID_CLIENT | DATE_CLIENT | ATTRIBUT ----------+-------------+--------- 000000001 | 2010:03:01 | 0000010 ----------+-------------+--------- 000000001 | 2010:02:16 | 0000010 ----------+-------------+--------- 000000001 | 2010:03:04 | 0000011 ----------+-------------+--------- 000000002 | 2...

Photos from last gallery

I have galleries and photos in all galleries. Is possible "in only one query" to list the photos of last the gallery? The last gallery is the most recently date For example: table "gallery" with field "data" and table "fotos" with fields "file" and "gallery_fk" Thanks ...

MYSQL query to find all rows that are outside join

I am trying to create a query which will return all rows of a table CLASSES that do not matched with another table named CHILD_CLASSES. These two tables look like this, The table CLASSES is a self referencing table so the top CLASS does not have a parent_id. The Parent ID row is created from the class_id row. So when I inserted A1 as a...

MYSQL update query to remove spaces

Hi One of my clients has added a number of account numbers in one of our applications. While trying to make a transaction the transaction fails due to the spaces at the end of the account number. How do i update his records in the Mysql database to remove all the spaces from accounts that have them at the end, without making him delete t...

Using LINQ with databases other than SQL Server Express 2005

I'm just starting to look into using LINQ for my database (and XML, and data object!) needs, but need to decide on which database to go with. I've been reading Pro LINQ, and it says that currently, LINQ in .NET 3.5 only supports SQL Server. I have done some googling, and have found references to using LINQ with MySQL and PostgreSQL (my...

MySQL find count query

Hi, I have table called stats. In am inserting yes or no in the table, and I want to show the number of yes count and the number of no count. Can somebody please help me with the query? ...

Get multiple GROUP BY results per group, or use separate concatenated table

I am working on an auction web application. Now i have a table with bids, and from this table i want to select the last 10 bids per auction. Now I know I can get the last bid by using something like: SELECT bids.id FROM bids WHERE * GROUP BY bids.id ORDER BY bids.created Now I have read that setting an amount for the GROUP BY results ...