mysql

Size of a Database transaction - Number of records

Hi, I have to insert approximately 96,000 rows in a table based on certain calculations. The business requirements is to have this operation in a single transaction, i.e. either all the entries are made successful or none. I am using MySQL and I could see the operation takes much more time than expected.. I shut down the operation afte...

Mysql Join Issue

Hi i need help with a query. I have 4 tables articles - id, category_id, user_id categories - id article_category - article_id, category_id users - id The category_id in the article table is used determine the main category Now I want to get all articles so i uses the query below. Article can have more than one category. I want to s...

Left Outer Join Query

I have two tables, one for bookings and one for room allocations. Booking table has an id and room allocations table has an id and room_id (id refers to the booking id). I want to find a list of all of the bookings who do not have an entry in the room allocations table. I made the following query: $sql = "SELECT booking.id, booking.use...

change time to EST in php and store in mysql

I have a report which will give me the time field as $time='Wed, 25 Aug 2010 13:43:38 +0000'. I am currently storing this into my MySql DB exactly like this and generating a custom report with the same time. I am in EST time so i want to know how i can change the $time field to show it according to 'Wed, 25 Aug 2010 09:43:38 '. i want t...

php mysql problem

I have installed php and mysql on windows xp with iis 5.1 as my web server. But when i run the following code it just shows me a blank page. Can anybody let me know where i am wrong. Thanks in advance. <?php $con = mysql_connect("localhost","root","xxxxxx"); if (!$con) { die('Could not connect: ' . mysql_error()); } ?> ...

Parse String to Organize By Row with PHP

Hello All, This is probably something easy to accomplish. I have some dates in my MySQL database, (and I am using PHP). Some are stored as such 2010-08-25 11:00:00, while others are stored as 2010-08-25T08:00:00 My question is: I am selecting the dates from the database, and then using ORDER BY start_date However, I have noticed tha...

MySQL: Lost connection to MySQL server during query then writing blob

Hello, I'm created table with one MEDIUMBLOB column and writing every second 2 images (16 or 32 KB) to this table. But random times i get Lost connection to MySQL server during query. Maybe i need to tune some mysqld server params or do something different ? I tested with local and remote mysqld server and i get same error. My code t...

Why are numbers being skipped in my auto-increment primary key?

Using MySQL 5.1.37 This isn't really a critical issue, one of our biz-dev people just asked about it and I didn't have a good answer. In our users table we have an auto-increment primary key. From time to time, it skips numbers and seems to be doing so at an increasing rate. My original thought was that when two concurrent signups oc...

Whats wrong with the query

Query issues, for the life of me i cant figure out what is wrong with this query HAVING distance ='10' GROUP BY c.ancient, c.ant_name, p.upper, p.name, ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'GROUP BY...

Problem with tables with foreign keys

I am trying to make a web application using Netbeans 6.5, MySQL 5.1, JSF, hibernate 3.2 and GlassFish. I want to insert the contents of a form in the database; it works fine when the table doesn't have foreign keys but it doesn't work when they do have them. I tried using Hibernate, and also using an SQL query directly, but it can't get ...

MySQL: Example of where to use the BIT Data Type

If I understand correctly, the pre MySQL 5.0.3 interpretation of the BIT data type meant it could be used as a series of flags? If this is the case I can see practical uses for it in MySQL but imagine it would not have been as efficient as using SET. Even if the above is not the case, I have great difficulty in understanding how the cur...

Table doesn't have a primary key

i get the following exception (missing primary key) in the line of using Find() method "Table doesn't have a primary key." I've rechecked the Database and all Primary Key columns are set correctly. my code: DataTable dt = p.GetAllPhotos(int.Parse(Id)); DataTable temp = new DataTable(); temp = dt....

Method for keeping track of "up" and "down" votes

I have a website that picks an entry from a database at random and then displays it to the user. I would like to add a "top rated" page on which the best entries as chosen by an aggregate of user opinions are displayed. I want up votes and down votes as seen here on stackoverflow and on many other websites. I am not very experienced wi...

SQL - fetch latest row with data in specific column or just latest row if no data in that column

I have a table that records a history of address updates, called transaction. The schema is something like row_id (int, PK), user_id (int), address1 (varchar), transdate (timestamp). I want to query the table and have a single row returned for a user showing what is the latest row (i.e. greatest timestamp), but if there is data in the ...

Finding value in a SQL table

Hi, I have a simple question here (I know it is so simple but I just got stuck...) I have a table tag_id, search_id 1,1 2,1 4,2 2,2 5,2 I would like to get the search_id by giving the tag_ids example: tag_id 1,2 would return search_id 1 tag_id 4,2,5 would return search_id 2 tag_id 2,6 would return no result. I should have pay more at...

Find *actual* character encoding of data in MySQL DB: UTF8 Latin1 illegal collation problem

Spent hours on this now and could use some help! Our website queries our db - table columns are set to Latin1 collation, website has set names to UTF8 for queries. The data is French and when we do a search for a string including accented characters we get the "*Illegal mix of collations (latin1_swedish_ci,IMPLICIT) and (utf8_general_c...

Non English characters appear as question marks on my php page - appear fine in database - please help

Hi guys, I have a mysql database tabel populated with non english data. When I view the data in Navicat MySQL browser the data appears fine. However when I run a php script to seelct and display the data on a web page it displays question marks instead. The page encoding is set to utf8 and even the mysql collation is set to utf8 - someth...

Mysql / Php - printing when theres only a single record

Whats the best way to print from mysql using php when you know theres only going to be a single record. My Sql is "select user from users where user = 'norman'; This will return only a single record. So what's the best way to print it? I currently do: while ($info=mysql_fetch_assoc($data)) etc etc But thats ok for more than one record...

MySQL: Unable to fulling forward engineering Sakila (sample) into server

After download the Sakila (sample), I have try to forward engineering this Schema into the server but only part of the table was engineered. Later synchronize also fall. Please take a look the report below and tell me is what wrong. I dont have programming background. If someone have successfully forward engineer Sakila fully, let me kn...

Using a variable in MySQL Select Statment in a Where Clause

I would like to know if it's possible to find a value in a select statement and use it in a where clause like: SELECT col1, MAX(col2) - COUNT(DISTINCT col3) as variable FROM table WHERE col1 > variable "table" is pretty big, and I want to narrow down the records the query has to look at as quickly as possible. I know this isn't bit ...