mysql

MySQL database config in a seperate class

Is it possible to keep all my database related configuration (hostnames, usernames, passwords, and databases) as well as the function to connect to and select the correct database in a seperate class? I tried something like this: class Database { var $config = array( 'username' => 'someuser', 'password' => 'somepass...

Remote (Non-LocalHost) MySQL Calls... Safe/Recommended for Management Purposes?

I'm new to MySQL and I'm using a desktop DB management app called "Querious" to simplify the process while I learn. I want to work on (mainly just structure & basic population) a database that's hosted elsewhere, but the host won't allow any remote MySQL calls on their server. What is their reasoning for restricting MySQL calls to lo...

connecting to mySQL

One of the ERP applications I worked with was configured in such a way that there was only 1 user (for example USER A) who connected to the database. Any user of the application (workforce was in the thousands) who logged on to the system and tried to do anything was in effect calling USER A to connect to the database and execute queries...

Is there cleaner syntax for WHERE id != 1 AND id != 2 AND id != 7

Is there a cleaner way to perform this query in MySQL? SELECT * FROM table WHERE id != 1 AND id != 2 AND id != 7 like: SELECT * FROM table WHERE id != (1,2,7) ...

MySQL DAYOFWEEK() - my week begins with monday

I'm using DAYOFWEEK() function in MySQL which returns 1 for sunday. But in my country the week starts with monday, not sunday. Is there any chance to get dayofweek from MySQL formated like: (1 - Monday, 2 - Tuesday, ...) ? ...

MySql query over many-to-many relationship

A very simple example of a n:m relationship that puzzles me. Let's assume we have two tables "Plant" and "Attribute" and another table between them holding their relationship with their IDs: Plant--------hasAttribute--------Attribute P1 | A1 P1 | A2 P1 | A3 P2 | A1 ...

PHP & MySQL on Mac OS X: Access denied for GUI user

Hey! I have just installed and configured Apache, MySQL, PHP and phpMyAdmin on my Macbook in order to have a local development environment. But after I moved one of my projects over to the local server I get a weird MySQL error from one of my calls to mysql_query(): Access denied for user '_securityagent'@'localhost' (using pass...

php mysql connection confusion

Hi guys, had a bit of confusion going around in work earlier. Thought id run it by yous to see if anyone knows wats going on. Were working on an internal administration system for our client, and its rite about to launch. Its comprised of TWO MySQL databases on the server [db_1 and db_2] and a PHP front end. [Both databases contain seve...

Why the size of MYD file is so high?

While i was creating stress data for a table i found the following files are generated. -rw-rw---- 1 mysql mysql 8858 Jul 28 06:47 card.frm -rw-rw---- 1 mysql mysql 7951695624 Jul 29 20:48 card.MYD -rw-rw---- 1 mysql mysql 51360768 Jul 29 20:57 card.MYI Actually i inserted 1985968 number of records in this table. But the index ...

How do I easily determine the age from an birthday? (php)

Possible Duplicate: Calculate years from date Hi, I have a table with a field representing the birthday. How do I find the age of the person from that date? This is what I have. $qPersoonsgegevens = "SELECT * FROM alg_persoonsgegevens WHERE alg_persoonsgegevens_leerling_ID = $leerling_id"; $rPersoonsgegevens = mysql_query(...

Database portability (sql server to mysql, postgresql)

I am working on a business app (asp.net). Right now I am using sql server. But I plan to support at least mysql and postgresql down the road. What are the issues that I should consider to avoid future headaches? Especially about datatypes (column types). E.g. I think BIT column is not supported on some dbs so I use tinyint? I mostly u...

Which DATATYPE is better to use TEXT or VARCHAR?

This question is based on two things performance and size Which DATATYPE is better to use TEXT or VARCHAR? Based on performance which will affect and which will impove? ...

How to prevent a full table scan when doing a simple JOIN?

I have two tables, TableA and TableB: CREATE TABLE `TableA` ( `shared_id` int(10) unsigned NOT NULL default '0', `foo` int(10) unsigned NOT NULL, PRIMARY KEY (`shared_id`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1 CREATE TABLE `TableB` ( `shared_id` int(10) unsigned NOT NULL auto_increment, `bar` int(10) unsigned NOT NULL, K...

Compressed and decompression column in mysql

I am trying to do compress/decompress while storing in mysql. Does it affect the performance? ...

WHERE id_property = 1 AND id_property = 2

Consider: SELECT id_post FROM post_property WHERE id_property = 1 AND id_property = 2 Sure you're thinking to use IN() SELECT id_post FROM post_property WHERE id_property IN (1,2) But that give me 2 rows as result, and I just need to get all the id_post that matched with the 2 properties Thanks a lot for your time! ...

Plan for building xml file containing custom designed blog posts/comments for import into WordPress via Clojure

I'm trying to migrate from a custom designed blog software system to a WordPress.com site. I can access my MySQL database of posts and comments without too much difficulty, thanks in part to this post: http://stackoverflow.com/questions/613929/how-do-i-connect-to-a-mysql-database-from-clojure. I think my next step is to generate the ps...

MySQL Select JOIN 3 Tables

Hi All, I've got sort of a 'tricky' one here-- well, maybe not. I have three basic tables: tblUsers: usrID usrFirst usrLast 1 John Smith 2 Bill Jones 3 Jane Johnson pm_data: id date_sent title sender_id thread_id content 2 ...

How do I ask for help optimizing & fixing queries in MySQL?

MySQL questions are some of my favorites on StackOverflow. Unfortunately, things like this: SELECT foo, bar, baz, quux, frozzle, lambchops FROM something JOIN somethingelse ON 1=1 JOIN (SELECT * FROM areyouserious) v ON 0=5 WHERE lambchops = 'good'; make my eyes bleed. Also, attempts at describing your schema often go like this: ...

How do I search for a two character word using a MySQL query?

I'm using MySQL FULLTEXT search (in Natural Language mode). Example: SELECT Mem_id FROM Members WHERE MATCH (job_title) AGAINST ('".mysql_real_escape_string($keywordsWanted)."') I noticed that searching for "web developer" or "PHP coder" didn't work too well and so I added ft_min_word_len=3 to the MySQL config file (/etc/mysql/my.cnf)...

Read multiple records given array of record IDs from the database efficiently

If you have an array of record ID's in your application code, what is the best way to read the records from the database? $idNumsIWant = {2,4,5,7,9,23,56}; Obviously looping over each ID is bad because you do n queries: foreach ($idNumsIWant as $memID) { $DBinfo = mysql_fetch_assoc(mysql_query("SELECT * FROM members WHERE mem_id ...