mysql

mysql group by to return a the min value and get the corresponding row data

I have a table of data like so : - PK_table - merchantName - price - Product - 1 - argos - 7 - 4 - 2 - comet - 3 - 4 - 1 - Dixon - 1 - 3 - 1 - argos - 10 - 4 I wish to select the minimum price for a product and the corresponding merchant in mysql. I tried: SELECT...

Mysql Duplicate Rows ( Duplicate detected using 2 columns )

How to remove duplicated in this setup? id A B 1 apple 2 2 orange 1 3 apple 2 4 apple 1 In here I want to remove (apple,2) which occurs twice. The id numbers are unique. I would use DISTINCT keyword if it were not. Can I some how make a key out of columns A and B and then use the DISTIN...

MySQL merge tables with different structure

I have two databases with different structure. Table 1: ch_code ch_def ch_weight Table 2: address ch_code I need to merge this two tables, so the structure would look like: ch_code ch_def ch_weight address The number or rows in two tables are different (table 1 has more data). Should I use merge, union.. some...

PHP Comment Code Help

Hi guys! I'm in the process of coding my very first blog. With the help of various tutorials, and other forums I have managed to gather a semi-working code. Right now I have a code that takes and displays the comment, but the problem is coordinating which comments go on which post. My current set up is all my post are HTML files, and t...

mysql restoring data on localmachine where the password is empty

I use a ruby program to download data from staging server and to populate that data to my local mysql server where the userid is root and password is empty. cmd = "mysql -u #{user} -p'#{password}' my_db < out.sql" Since password is empty, I get prompted for password. I just have to hit enter. I would like to avoid that. What's the f...

mysql data file problem

hello i had to recover my mysql databases by moving old mysql data file into a new installation of mysql(e.g. mysql 5.1/data/[database]). all the databases are accounted for, but some of the tables are not showing up in phpmyadmin. it would say 11 tables in the dropdown but only show 7. anyone have any idea? thank you when i run C:\P...

PHP/MySQL mailing list, mailer and subscription classes

I am working on a project that needs a emailable mailing list built into it with a very complex list structure. Originally I thought I could just use PHPList to do the job with some minor alterations because of its list management. But now I'm finding that I'm going to need to build this from scratch. PHPList is way to complex to make tw...

MySql PHP results.

Hi i'm working on some code with mysql and need to display the mysql results with php.. MySQL select distinct(year(Cataloged_Date)) from records; +------------------------+ | (year(Cataloged_Date)) | +------------------------+ | 2009 | +------------------------+ 1 row in set (0.00 sec) PHP foreach($query->result() ...

Grouping to extract common values in semi-structured data

I've got a 'somewhat' ugly field in a database which holds the names of locations. For instance, Madison Square Gardens which has also been entered as "The Madison Square Gardens", etc. etc. I'm trying to extract the data so that I can get an accurate list of all the locations. In order to accomplish this, what I've done is created a ...

Import Multiple CSV files into MySQL with Python

Hi All, I am trying to use examples that are fun/interesting to me in order to learn MySQL and Python. I am new to both, as I am a finance guy by trade. I have learned quite a bit along the way, but I am at a point where I am not sure where to go. The data files I am looking to import are contained in a zip file, hosted: here I ext...

while loop in a while loop

Hello I have a while loop that goes through a table and I echo the results within it, I also have a while loop that looks at a image directory and I can output the paths to images. My problem is I want to output the image path in the other while loop where my html and image tag reside. I have tried putting one while loop inside the othe...

mysql5-client connects to mysql4-server

I installed mysql-5.1 into my server and mysql-4.1 has been installed already. Then, I realized that I can connect from mysql-5.1 client to mysql-4.1 server like this. [hoge@localhost:/usr/local/mysql5/bin]% ./mysql -u root -pXXXXXX -P 3306 -S /tmp/mysql4.sock I can use select query to mysql-4.1 server. Is there any restriction in this...

MySQL and C : undefined reference to `_mysql_init@4'|

I'm trying to write a simple script for C to get values from a MySQL database, but it's throwing this error 'undefined reference to `_mysql_init@4'' Don't know if I'm not linking to something I should be? My C knowledge is limited... I'm using Code Blocks on Windows, here's my code: #include <winsock.h> #include <C:\mysql\include\mys...

Tracking the views of a given row

Hi there, I have a site where the users can view quite a large number of posts. Every time this is done I run a query similar to UPDATE table SET views=views+1 WHERE id = ?. However, there are a number of disadvantages to this approach: There is no way of tracking when the pageviews occur - they are simply incremented. Updating the ta...

mysql missing field after running rails db migration

i have a rails migration: >> cat db/migrate/20091126031039_create_cards.rb class CreateCards < ActiveRecord::Migration def self.up create_table :cards do |t| t.string :number_hash t.int :number t.string :name t.string :type t.string :expiration t.int :sec_code t.timestamps end end ...

mysql join query

I have a query with the following tables (reduced to show only the interested columns). t1 code t2 code, period, status t3 period, desc Now what I have is, t3 is a table of unique "periods". t1 is a table of unique codes. t2 is the join table linking both together, along with a status, for sake of this example status=(A,B,C). Wh...

PHP MYSQL Excel to xls ?

This my example code: $objPHPExcel->setActiveSheetIndex(0); $objPHPExcel->getActiveSheet()->SetCellValue('A2', '1.0'); $objPHPExcel->getActiveSheet()->SetCellValue('B2', '0.0'); $objPHPExcel->getActiveSheet()->SetCellValue('C2', '1.2'); $objPHPExcel->getActiveSheet()->SetCellValue('D2', '100'); Iam getting in excel sheet is round off v...

What is the correct syntax for SQL Statement using MySQL

In access i used this and its works fine: (tblReservations_Dates.Date) Between #" & dteBegDate & "# And #" & dteEndDate & "# Using MySQL I used this: (tblReservations_Dates.Date) Between '" & dteBegDate & "' And '" & dteEndDate & "' However the data is not displayed I was just wondering if this is the correct syntax for SQL Stateme...

How to view MySql Fulltext Indexs?

Does MySql Fulltext search use Indexing? If so, how can I view the Index entries table? I can view the Index Statistics with VIEW query. But, I just wanted to view the index record entries table. Thanks. ...

MYSQL server has gone away

Hello All, I am using WAMP server for my web application . Sometimes I see this General error: 2006 MySQL server has gone away' I am updating the MySQL database through PDO PHP. Any suggestions to avoid this ? ...