mysql

How to Loop & rename MySQL table in Perl

Hi, Could you plesae teach me how to Loop & rename MySQL table in Perl. Thanks. my code snippet attached use strict; use warnings; use DBI; my $dbh = DBI->connect( 'DBI:mysql:database=dbdev;host=localhost', 'dbdev', 'dbdevpw', { RaiseError => 1, AutoCommit => 1 }, ); my $sql = RENAME TABLE old_table TO new_ta...

how can i get the total from the four different table in single query

In each table have many number of rows with amount. Like this i have different numbers of amount in each table. Each tables field name is different. How can i get the total of all values in the four tables in a single query? Any way is there? ...

How to grab dynamic content on website and save it?

Hello! For example I need to grab from http://gmail.com/ the number of free storage: Over <span id=quota>2757.272164</span> megabytes (and counting) of free storage. And then store those numbers in a MySql database. The number, as you can see, is dynamically changing. Is there a way i can setup a server side script that will be grabb...

How do I conditionally select a field from one of two tables?

I have two tables invoices and pending_payments both of which have the following rows in common: invoice_id and balance. I want to do a select in MySQL that'll work thus: [pseudo-code] if(invoice_id exists in pending_payments table) { select balance from pending_payments where invoice_id = yadayadayada } else { select balance f...

Synchronize model in MySQL Workbench

After reading the documentation for MySQL Workbench I got the impression that it's possible to alter a database in the server (e.g. add a new column) and later incorporate the DDL changes into your EER diagram. At least, it has a Synchronize Model option in the Database menu. I found it a nice feature because I could use a graphic modell...

Indexing SET field

I have two entities A and B. They are related with many to many relation. Entity A can be related up to 100 B entities. Entity B can be related up to 10000 A entities. I need quick way to select for example 30 A entities, that have relation with specified B entities, filtered and sorted by different attributes. Here how I see ideal solu...

MySQL data file won't shrink

My ibdata1 file for MySQL database grew to about 32GB over time. Recently I deleted about 10GB of data from my databases (and restarted mysql for good measure), but the file won't shrink. Is there any way to reduce the size of this file ...

Best way to implement keywords for image upload gallery

I'm starting to spec out an image gallery type system similar to Facebook's. Members of the site will be able to create image galleries and upload images for others to view. Images will have keywords the the uploader can specify. Here's the question, what's the best way to model this? With image and keyword tables linked vi a HABTM r...

What are the reasons to use SQL Server instead of MySQL with a complex .Net project?

We currently have a 10 year old nasty, spaghetti-code-style SQL Server database that we are soon looking to pretty much re-write from scratch as part of a re-write to a large web application. (The existing application will serve as the functional requirements for the next incarnation of the app) The new version will be developed in .Net,...

How to store MySQL warnings in database?

I'd like to store warnings caused by some SQL statements in the database. E.g. after mysql> select 1/0; +------+ | 1/0 | +------+ | NULL | +------+ 1 row in set, 1 warning (0.00 sec) mysql> show warnings; +-------+------+---------------+ | Level | Code | Message | +-------+------+---------------+ | Error | 1365 | Division by 0 |...

order keywords by frequency in PHP mySql

Hello, I've got a database with video ids and N keywords for each video. I made a table with 1 video ID and 1 keyword ID in each row. What's the easiest way to order keywords by frequency? I mean to extract the number of times a keyword is used and order them. Is it possible to do that with sql or do I need to use php arrays? Thank...

Doctrine SQL query: works on MySQL, on PostgreSQL won't

This is a query automatically generated by Taggable extension for Doctrine ORM. SELECT t.id AS t__id, t.name AS t__name, COUNT(DISTINCT i.id) AS i__0, (COUNT(DISTINCT i.id)) AS i__1 FROM taggable_tag t LEFT JOIN cms__model__image_taggable_tag c ON (t.id = c.tag_id) LEFT JOIN image i ON i.id = c.id WHERE t.id IN (SELECT doctrine_s...

Retrieve blob field from mySQL database with MATLAB

I'm accessing public mySQL database using JDBC and mySQL java connector. exonCount is int(10), exonStarts and exonEnds are longblob fields. javaaddpath('mysql-connector-java-5.1.12-bin.jar') host = 'genome-mysql.cse.ucsc.edu'; user = 'genome'; password = ''; dbName = 'hg18'; jdbcString = sprintf('jdbc:mysql://%s/%s', host, dbName); jdb...

Why would restarting MySQL make my site faster?

hey all, my site started dragging lately, the queries taking exceptionally longer than I would expect with properly tuned indexes. I just restarted the mysql server after 31 days uptime and every query is now substantially faster and the whole site renders 3-4 times faster. Would there be anything that jumps out at you as to why this ...

Show number of results in each "filter item"

Hi ! How can i get the number of each filter item in a seach? Example... im doing a job/resumes portal... i seach a job title and i have some filters items like City, State , area and etc... How can i show the number of each filter in the select box example Contry: Brazil(22 results), USA(61 results) Here a url with a sample: http://w...

LIMIT then RAND rather than RAND then LIMIT

I'm using full text search to pull rows. I order the rows based on score (ORDER BY SCORE) , then of the top 20 rows (LIMIT 20), I want to rand (RAND) the result set. So for any specific search term, I want to randomly show 5 of the top 20 results. My workaround is code based- where I put the top 20 into an array then randomly select 5....

PHP & MySQL submit error message problem

When I submit a new name and not a new avatar I get the following avatar error message Please upload a .gif, .jpeg, .jpg or .png image!. I want to be able to send a new name only without having to upload a new avatar each time I submit the form without getting the avatar error message Please upload a .gif, .jpeg, .jpg or .png image! can ...

php for-loop issue

Heya, I have a loop which generates a table code for a specific number of times. What I'm having problems with is to echo a variable inside the loop. The loop runs 10 times, and there are 10 text messages sent to the page, so my problem is how do I get each of the looped tables to echo one of the text messages each time? ...

unable to install mysql completely on debian 5.0

hi, its been a couple of days that I'm trying to install mysql on my vps which has debian 5.0 with 256mb ram. I've installed webmin also. here is the symptoms : after installing mysql using either webmin or apt-get I am trying to connect to mysql for changing root password but every time I cope with this error : ERROR 1045 (28000): Ac...

How Do I See The Final Text Of A Query Resulting From A Call To mysqli->prepare?

After code like this: $stmt = $mysqli->prepare("SELECT District FROM City WHERE Name=?")) { $stmt->bind_param("s", $city); $stmt->execute(); $stmt->bind_result($district); $stmt->fetch(); printf("%s is in district %s\n", $city, $district); How Do I See The Actual SQL Statement That Was Executed? (It Should Look Something Like "SELECT...