mysql

mixing auto_increment and non in mySQL

Hi-- I have a set of tables where each table's ID key is auto_incrementing. Now my users want to import a bunch of external data that has different keys from a single csv flat file. I think the best way to do it is to lock the tables, grab the next value for the auto_increment column for each table, then for each row I insert just swap ...

[Exists] Use PostgreSQL as a storage engine in MySQL?

Several programs demand that the underlying DB is MySQL. Similarly, software like GridSQL demand that the underlying database is PostgreSQL. If they were integrated then, there would be a wealth of advantages including: Easier migration between the two. Possibly the ability to use MySQL replication with PostgreSQL Ability to use softw...

Java switch from MS SQL to MySQL - Character sets

Hi Folks, I am developing an application connecting to a database in Java. The customer has SQL Server and I tried the SQLExpress version von Microsoft as long as we don't want to buy a licence for the developement time. Sadly, the SQL Server Express does not allow network access so we can't work over network on the same database and ha...

MYSQL JOINs returning more results than it should.

I wasn't too sure how to present this question to keep it consise while still giving plenty of info to work with. If any one needs more info/tables let me know and I'll be happy to edit. I'm trying to query a database and need to join several tables to get the data I want. The query is: Show me amount of items from supplier x that were...

safest place to store php values for msql_connect ?

Hi , Were is the safest place to store my values which will be used in mysql_connect also what is the safest way to call these variable would be better using a require , include or something else ? thanks :) ...

Duplicate Entry errors using Shoulda Macros

I wrote some tests for a several models and controllers of a Rails application using Shoulda macros, but one after another they each fail with the error ActiveRecord::StatementInvalid: Mysql::Error: Duplicate entry '1' for key 1: INSERT INTO `replies` (`created_at`, `from_user`, `updated_at`, `read`, `text`, `tweeted_at`, `id`, `user_id...

How can I get the Primary Key id of a file I just INSERTED?

Earlier today I asked this question which arose from A- My poor planning and B- My complete disregard for the practice of normalizing databases. I spent the last 8 hours reading about normalizing databases and the finer points of JOIN and worked my way through the SQLZoo.com tutorials. I am enlightened. I understand the purpose of data...

what is the best way to create random mysql ID using PHP

hello. i'm building an application that needs a random unique id for each user not a sequence mysql database ID Username for my unique random ID, what is the best way to do that? ...

ActiveRecord select attributes without AR objects

I have a table with MANY rows, I need just the IDs of certain rows. The slow way is to call SomeARClass.find(:all, :conditions => {:foo => true}, :select => :id) This returns AR Objects... Is there a way to call a select on a class and have it return a plain old ruby data structure. Something like this: SomeARClass.select(:id, :con...

Import/Exporting databases from one machine to another

I have two PCs, one is Ubuntu 8.10 and the other Ubuntu 9.10. On the Ubuntu 8.10, i have a few databases in phpmyadmin which i would like to copy across to the Ubuntu 9.10 phpmyadmin(which has no databases). I'm not sure if i'm on the right path but here's what i think i should do: Export the databases onto Ubuntu 8.10. And copy those...

What's the difference between VARCHAR(255) and TINYTEXT string types in MySQL?

What's the difference between VARCHAR(255) and TINYTEXT string types in MySQL? Each of them allows to store strings with a maximum length of 255 characters. Storage requirements are also the same. When should I prefer one over another? ...

Can I use zero in a column which has the AUTO_INCREMENT attribute

Hi, I'm using a MySQL 5.0 server. My requirement is to add one special row to an existing table which has an auto-increment primary key. It would be very useful for future maintenance and management of the project if we were able to make the id of this row 0 (because it's easy to remember and easy to spot in manual observations). Now, ...

PHP Register Script - Not working...

I just made a register script from scratch, but I'm still going to improve it. Basically I'm testing it first before I improve it - somehow, it doesn't work... if(isset($_POST['submit'])) { $username = mysql_escape_string(trim($_POST['login'])); $password = $_POST['password']; $vpassword = $_POST['vpassword']; $email = mysql...

PHP Forums - how to cope with unread discussions / topics / posts

Hi, I know this question has been asked here a couple of times, but none of the answers had pleased me. This is because almost all of them involve a huge read / write process related with the database, which I'd like to avoid at all cost. About unread discussions / topics / posts, there's a lot to think of. Don't know how do forum sys...

MySQL JOIN ON with WHERE

I have 2 tables and want to query all the album data joined with the artist artists: artist_id | name albums: album_id | artist_id | songs This gives me only the first row SELECT * FROM albums JOIN artists ON artists.artist_id = albums.artist_id I want to specify an album id SELECT * FROM albums WHERE album_id = 101 JOIN arti...

how can I tell if mysql_real_escape_string is working

Hi , As it says in the title , how can I tell if the mysql_real_escape_string is working how it should without waiting to be hacked ? ...

Alter MySQL column with values to auto increment

Hi all, I had a hard time with the title, so let me explain. What I'm doing is using the jQuery UI to create sortable list elements on a page. Once the order is submitted, php assigns an incrementing value to the list elements based on their order, drops the existing id column, creates a new id column and inserts each list elements valu...

mySQL: Updating multiple values in a record with a SELECT from another table

Trying to sort out the correct syntax for this UPDATE: UPDATE `foo` SET (`x`, `y`, `z`) = (SELECT `x`, `y`, `z` FROM `bar` WHERE `id` = 'baz'); In the actual query, there are 165 columns so I very much do not want to have to do x = x for each column. The columns are not a p...

3 Table Join in MySQL

Hello! Say I have 3 tables. Table1 contains client_id and client_name. Table2 contains client_id, client_catid_1, and client_catid_2. These to tables are joined based on the, client_id. Now the third table, contains category_id and category_name. How can join the third table based on the category id's and get the category_name? example...

is there a gem used to store rails logs in mysql?

I finally have my application written, and now I have a request to store the logs into a mysql db for later searching. Any ideas besides log4r? Thanks! Tonya ...