mysql

mysl mysam table, temporary table and index

Would it be faster to add index for "t.name"? Does the index for "t.name" is preserved when the temporary table "x" is created? SELECT x.id FROM (SELECT t.name FROM t WHERE id_group=1 LIMIT 2000) AS x WHERE x.name LIKE 'a%' LIMIT 0,12 ...

mysql for dummies

I just started using MySQL and I just can see myself woking with strings! I mean the compiler can't catch errors like this and it's just a mess! Is there a wrapper or some kind of class I can add that does something as simple as making a function that adds a table and asks for args? I'm sure there is a tool like that but I can't find it...

ODBC How to store a variable length array of strings?

Y.A.N.Q. (yet another n00b question). I have managed to design my db, defining tables & columns. I have even got code to access the db, yay! Now, one bit that I haven't yet gotten to in the "MySql weekend crash course". Let's say that I want to store something like "notes" which is a TStringList sort of thing. A list of strings which...

MySQL - are FK's useful / viable in a web app?

Hi all, I've encountered this discussion related to FK's and web applications. Basically some people say that FK's in web applications doesn't represent a real improvement and can even make the application slower in some cases. What do you guys think, what's your experience? edit : note that I'm aware of FK's job and objective, I'm ju...

Counting multiple rows in MySQL in one query

I currently have a table which stores a load of statistics such as views, downloads, purchases etc. for a multiple number of items. To get a single operation count on each item I can use the following query: SELECT *, COUNT(*) FROM stats WHERE operation = 'view' GROUP BY item_id This gives me all the items and a count of their views. ...

htmlspecialchars() - How and when to use and avoid multiple use

Hi, I'm building a PHP intranet for my boss. A simple customer, order, quote system. It will be denied access from the Internet and only used by 3 people. I'm not so concerned with security as I am with validation. Javascript is disables on all machines. The problem I have is this: Employee enters valid data into a form containing an...

How to prevent PHP variables from being arrays or objects?

I think that (the title) is the problem I am having. I set up a MySQL connection, I read an XML file, and then I insert those values into a table by looping through the elements. The problem is, instead of inserting only 1 record, sometimes I insert 2 or 3 or 4. It seems to depend on the previous values I have read. I think I am rein...

What happens if MySQL database wasn't closed?

What happens if MySQL database is not closed? How do we know if it is closed properly? I do have a page which has 11 tables on a page..so what I did is I open database on top of page before script starts and close where the scripts(PHP) ends... the ending is mysql_close($db);...is this fair enough or do I need to give only mysql_close(...

MySQL specifying exact order with WHERE `id` IN (...)

Is there an easy way to order MySQL results respectively by WHERE id IN (...) clause? Example: SELECT * FROM articles WHERE articles.id IN (4, 2, 5, 9, 3) to return Article with id = 4 Article with id = 2 Article with id = 5 Article with id = 9 Article with id = 3 and also SELECT * FROM articles WHERE articles.id IN (4, 2, 5, 9, 3...

Giving upload folder these permissions safe or not?

I have a classifieds website with a picture script for uploading pics onto the ads. The pics are uploaded to the "images" dir. The php code which does this requires write access to the directory I am guessing... So, what permissions would you set to the php upload file, and the images directory? I am thinking like this: drwxr-xr-x ...

mySQL query: How to insert with UNION?

Hi everybody, I am kind of new to mySQL:s union functions, at least when doing inserts with them. I have gotten the following to work based upon a example found on the net: INSERT INTO tableOne(a, b) SELECT a, $var FROM tableOne WHERE b = $var2 UNION ALL SELECT $var,$var Ok, nothing strange about that. But what happens when I want ...

Apache Virtual Hosts with Multiple wordpress blogs.

Hi, I'm running a VPS @ slicehost with Linux 9.10. I've got a basic Lamp setup so far. I am hosting a few sites and adding a half dozen more, and I'd like almost all of them to have word press blogs available. I tried installing wordpress into each directory following the normal instructions thinking that apache virtual hosts, since...

Long running transactions with Spring and Hibernate?

The underlying problem I want to solve is running a task that generates several temporary tables in MySQL, which need to stay around long enough to fetch results from Java after they are created. Because of the size of the data involved, the task must be completed in batches. Each batch is a call to a stored procedure called through JD...

How do i run a query in MYSQL without writing it to the binary log

I want to run an import of a large file into MySQL. However, I don't want it written to the binary log, because the import will take a long time, and cause the slaves to fall far behind. I would rather run it seperately on the slaves, after the fact, because it will be much easier on the system. The table in question is a new one, and ...

check if a table exsist in where

This query generates an error because table2 doesn't exist: Select * FROM table WHERE table2.id IS NOT NULL Is there anything like this for check the table2 before apply the check on the id? Select * FROM table WHERE (EXIST(table2) AND table2.id IS NOT NULL) or not EXIST(table2) Thanks ...

how to avoid sub-query to gain performance

hi i have a reporting query which have 2 long sub-query SELECT r1.code_centre, r1.libelle_centre, r1.id_equipe, r1.equipe, r1.id_file_attente, r1.libelle_file_attente,r1.id_date, r1.tranche, r1.id_granularite_de_periode,r1.granularite, r1.ContactsTraites, r1.ContactsenParcage, r1.ContactsenComm, r1.DureeTraitementContacts, r1...

MySQL Accept Any Password

Suppose that I have a test server with a large group of test accounts. The test accounts have unknown passwords which are hard-coded into the application's reports and are stored encrypted in the mysql.users table. Is there any option or hack which can be used to make mysql accept any text as the "correct" password for an account? For e...

Program to open large MySQL dumps

Is there a GUI program that can read large MySQL dumps (+200MB), or really any large text file? Most modern editors it seems can't handle large files because it seems they like to load the whole file into memory. I want to open it on Ubuntu (Linux), but I would also like to read it on Windows. ...

PHP database simulation

I have a PHP script that works by calling items from a database based upon the time they were placed in there and it deletes them if they are older than 5 minutes. Basically, I want to now simulate what would happen if this database was being updated regularly. So I was considering sticking in some code that loads an XML file then goes ...

How to triage this MySQL duplicate entry error after running Rails migration?

I get the following error when I try to run this migration: == AddUniquenessConstraintOnAwards: migrating ================================ -- add_index(:awards, [:badge_id, :game_week_id], {:unique=>true, :name=>:game_badge_index}) rake aborted! An error has occurred, all later migrations canceled: Mysql::Error: Duplicate entry '35-81...