mysql

Simple query not working

The simple query below is not returning any results. I can't see any errors in it. Any idea why it's not working? $sqlStr3 = "SELECT loginid, username, created FROM login ORDER BY created DESC LIMIT 200"; $result = mysql_query($sqlStr3); $count...

MySQL DateTime Format with c# failing

HI I am writing a sample application to insert and retrive datetime format . The Insert i did was sucessfull but dont know why it fails when i query to retrieve it . . My insert goes like this.. string SqlQuery = "INSERT into BenchMarking Values (" + i + " , 'XXXX','This is a testing','M','2010-05-05 05:06:01')"; sqlWrapper.Exe...

performing mysql transactions with master and slave setup?

how do you deal with transactions when you have master and slave db setup? typically i do all the reads from slaves and writes from master but when performing transactions, it seems i need to do reads from master (the one which is performing the transactions) and so i can't have all my transactions all in one place ... im also using ze...

LOAD DATA LOCAL INFILE keeps crashing

Hello folks, I am loading a large text file into my db through LOAD DATA. The file is about 122,000 lines long. Let alone, The db is designed to be triggered on AFTER INSERT's on that table. What happens exactly is that the query begin executing, keeps executing for like 15-20 mins and then it returns Error Code: 2013 Lost connection ...

PHP, MySQL, and AES Encryption / Decryption for User Data

I am new to AES encryption but trying to build a solution which: Accepts consumer data Encrypts that data using AES and a "public" key Store that data in a MySQL database Have the ability to pull and decrypt the data ONLY with a private key (stored on my personal machine, not the server itself). I realize this may be overkill but wan...

Using @GeneratedValue(strategy=GenerationType.TABLE), the sequence_next_hi_value is an int(11) but my table have a id column bigint(20)

Hello, I am using @Id with @GeneratedValue(strategy=GenerationType.TABLE), just checked that hibernate have created a table hibernate_sequences, but the column type for the sequence_next_hi_value is an int(11). I have some entities (I mean tables) that have an id field of type bigint(20), will that works ? and when my table reach the nu...

Displaying MySQL results from a relation of a relation

If I have three tables, and I'm trying to loop through all posts: posts: post_id, post_title, post_content tag_relations: post_id, tag_id tags: tag_ig, tag_name If each post will have multiple tags, how would I display each tag for each post? As in, how would I have to setup my SQL query, and how would I print the results? Would it b...

Need to put @Index even when I marked with @Column(unique=true) ?

Hello, Need to put @Index even when I marked with @Column(unique=true) ? I have a property that will be used frequently to retrieve the entity and wanted to make it an index column on the database. So this property is already marked with @Column(unique=true), do I need to put @Index? thanks ...

Engine select with SOURCE in mysql

How do I change the engine to MyISAM when using a SOURCE import in mysql? It currently defaults to InnoDB. would there be any difference between the speed of the import between the engines for say a 5gb .sql file? ...

Making a CSS background rectangle appear when a field equals 1

The code below echoes out an HTML table, populated with values from a MySQL database. The CSS changes when a field called "topten" equals 1. When "topten" equals 1, I would like to have a rectangular background 100 pixels high, 800 pixels wide, and color #A6FFFF;. When "topten" does not equal 1, I would like there to be no backgroun...

MySQL: Incorrect key file for table '/tmp/#sql_185e_0.MYI'; try to repair it

Hi, Incorrect key file for table '/tmp/#sql_185e_0.MYI'; try to repair it What does this error mean? "Incorrect key file for table '/tmp/#sql_185e_0.MYI'; try to repair it" I'm inserting 400k records in a table by 25k per batch using PHP in command line. If I inserted only 1k records then it will not produce the MySQL error. Does ...

memcaching php resouce objects

Say I have this code in PHP : $query = mysql_query("SELECT ..."); the statement returns a resource object. Normally it would get passed to mysql_fetch_array() or one of the mysql_fetch_* functions to populate the data set. I'm wondering if the resouce object - the $query variable in this case can be cached in memcache and then a wh...

Why is PHP mysqli prepared statement working but inserting all NULL values?

What would cause this? Code follows: $m = new mysqli($host,$user,$pass,$db); if(mysqli_connect_errno()) die('Connect failed: ' . mysqli_connect_error()); $PrepSQL = "INSERT INTO Products (" . implode(',',$this->cols) . ") VALUES ("; $PrepSQL .= '?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)"; $stmt ...

In MySQL, is it faster to delete and then insert or is it faster to update existing rows?

First of all, let me just say that I'm using the PHP framework Yii, so I'd like to stay within its defined set of SQL statement if possible. I know I could probably create one huge long SQL statement that would do everything, but I'd rather not go there. OK, imagine I have a table Users and a table FavColors. Then I have a form where us...

If I frequently ORDER BY o.creationDate - should I mark creationDate with @Index ?

I know that indexes on database are a good way to increase query performance, but how much performance I would gain by creating an index for a creationDate property of a given object that I frequently order by creationDate in my queries? Would this frequently "order by o.creationDate" justify creating an index for the creationDate proper...

SQL Syntax with regards to SELECT

I keep getting an error saying that a specific column, doesn't exist for b.BookCode But I am fully aware that it does exist! I just wanted to make sure after staring at this for so long that I am not missing something obvious. SELECT AuthorLast, AuthorFirst, OnHand, Title FROM (Inventory i, Author a, Book b) WHERE (i.BookCode = b.Book...

Subquery not in performance question

I have this slow query select * from table1 where id NOT IN ( select id from table2 ) Would this be faster by doing something like (not sure if this is possible): select * from table1 where id not in ( select id from table2 where id = table1.id ) Or: select * from table1 where table1.id NOT EXIST( select id from table2 where table...

how to parse an xml string in mysql?

in ms sql I have the following code: ALTER PROCEDURE [dbo].[xmlDictamen_Alta] @Xml text as begin declare @Id integer declare @DocumentoId numeric(18,0) declare @Descripcion varchar(300) begin set nocount on exec dbo.sp_xml_preparedocument @Id output, @Xml select @DocumentId = DocumentId, ...

How can I optimize this confusingly slow query in MySQL?

I have a table of blog posts, each with a foreign key back to it's author. There are < 15,000 entries in this table. This query scans over 19,000 rows (per EXPLAIN), requires a filesort (that might be regular MySQL behavior), and takes over 400ms to return 5 rows. possibly because of the complicated WHERE used to check if the item is act...

Errcode 13 error on delete of table

While attempting to drop a database in MySQL, an error message appears: MySQL said: Documentation # 6 - Error on delete of './bedrock/grouprec.MYI' (Errcode: 13 I was logged in as root user with all privileges. What's the cause of this error, and how can this be remedied? ...