mysql

how to group by and count using MySQL

I have data which looks like this: ID post_author post_title guid 3309 21 Should somebody not yet on SQL 2008 wait for SQL 2008 R2, since it's near release? http://sql.stackexchange.com/questions/379/should-somebody-not-yet-on-sql-2008-wait-for-sql-2008-r2-since-its-near-release 1695 429 How do we politely decline well meaning a...

How to make Doctrine use a MySQL TIMESTAMP column instead of DATETIME?

I'm looking for a way to use the MySQL timestamp column type in Doctrine 1.0. I was able to get it working by modifying Doctrine_DataDict_Mysql to return TIMESTAMP instead of DATETIME when the specified type is timestamp, but I'm fairly certain that it's not the right way, and it will probably break at some point. Doctrine 2.0 seems to ...

MySQL - Newbie question: Which are the PK and the FK for these tables?

I have 3 tables: Employees T emp_id | name | address Department T dep_id | name Salaries T emp_id | dep_id | month | year | salary For each table, what are the primary keys and the foreign keys? My answer: Name of the table | PK | FK| Employees: emp_id | dep_id Department: dep_id || emp_id Salaries: emp_id, dep_id | emp_id, d...

retrieve data from two columns with the same name but different table

I want to be able to select the column from users and dusers. example: select u.user, d.user FROM users u JOIN dusers .... etc. ...like so: echo $row['u.user'] echo $row['d.user'] I tried this, but no go. How do I specify what table to retrieve the user from? ...

Mysql db class - trouble connecting

So I'm trying to make a mysql database class, and I want to keep my db selection in a seperate method from the constructor. For some reason it the setDb() function doesn't want to work. class mysql { public function __construct($server,$user,$pass) { if(!$this->mysql_connection = mysql_connect($server,$user,$pass)) print 'Could n...

Mysql Ordering Query

Hello I want to run a query to get the last five records from a table, but in reverse order. Currently I have: $query = "SELECT * FROM Table ORDER BY id DESC LIMIT 5"; which isn't quite what I want. For example if the last five records are 15 16 17 18 19 I want them returned as 15 16 17 18 19 Not 19 18 17 16 15 which is what the ...

MySQL find authors without posts (one-to-many relationship)

Hi guys... I've a MySQL problem: I've two tables (posts and authors) in a one to many relationship (since each post is written by an author and an author can write multiple posts). So here are the tables: Authors: id:BIGINT, name:VARCHAR(255) Posts: id:BIGINT, author_id:BIGINT, body:TEXT. How can I retrieve all the authors with no po...

ini_set, set_time_limit, (max_execution_time) - not working

If I do set_time_limit(50) or ini_set('max_execution_time',50) when I echo ini_get('max_execution_time') on my localhost i get 50, when i do on another server it echoes the default 30 and completely ignores my request. why is this? ...

MySQL: Code To Compare 2 Tables, Then If row is the same update Master Date

I have two tables, they are called MASTER and NEWDATA. The schema on both tables is exactly the same and they contain the field names: CODE, SERIAL, MODEL, VALIDATED_DATE. I want to check if the values in the CODE field exists in the NEWDATA table and in the MASTER table. If they are in both tables, then I want to update the VALIDATED_D...

Mysql: How do you create a table with multiple primary keys?

I have this situation: http://stackoverflow.com/questions/1590033/mysql-newbie-question-which-are-the-pk-and-the-fk-for-this-tables (take a look at the table Salaries) How do you create a table with multiple primary keys? create table salaries ( dep_id smallint auto_increment primary key, emp_id smallint auto_increment primary ke...

MySQL InnoDB locking only the affected rows?

I have an InnoDB table containing users, like this: +--------------+-----------------------+ | user_id | name | +--------------+-----------------------+ | 1 | Bob | | 1 | Marry | | 2 | Bob | | 1 | John |...

Problem with Rhino-Etl and MySQL

I've been using Rhino-ETL for a little while and it's running pretty smooth. However I have a problem connecting to my MySQL DB. Rhino.Etl.Core.RhinoEtlException: Failed to execute operation Hornalen.Migration .Process.ReadMessagesFromDb: The type name 'MySql.Data.MySqlClient' could not be found for connection string: testConnectionStr...

Feed generator for PHP, allowing åäö and images

Hi, I'm new to feeds. I want to create feeds, so first, should I use rss 1, 2 or atom, whatever is best/standard? Second, do you know any easy to understand tutorials or code-examples? Any other good to know for feeds is more than welcome. I'm using php and mysql. Thanks in advance. /Johan ...

Doctrine PHP Question

I was wondering if you can specify the order in which table definitions and data fixtures are loaded using the CLI. My problem is that I have two tables, each having a foreign key constraint pointing to the other, so one of the constraints needs to be added after a record has been added. Or maybe there's a better way of doing this...I'm ...

SQL: joining 3 tables, needing to also join the 3rd to itself

This works if I remove the final JOIN line, but I'm not sure why it won't work with it. The last two JOIN statements are attempting to grab data ('meta_value') from different rows in the same table, the names of which can only be found by reading another corresponding column ('meta_key') in the same table. All this while joining everythi...

Two left joins and one query to MySQL performance problem

Hello, I'm designing a project for quizzes and quizz results. So I have two tables: quizz_result and quizz. quizz has primary key on ID and quizz_result has foreign key QUIZZ_ID to quizz identity. Query below is designed to take public quizzes ordered by date with asociated informations: if current user (683735) took this quizz and has...

How to create Gmail Chat? How to connect to AIM and allow for AIM chatting?

I want to know how gmail chat allows the user to connect to AIM and then chat as if he were logged on to AIM. Is this easy to make? How can it be done? Does anybody know of any similar open source tools? Thanks! ...

building first custom CMS and have been told to use Dreamweaver and a plug in called Horizontal Looper

Hi, so I'm in a little over my head right now and want to verify that i've been given good advice as for how to build this simple CMS site. It's a book site and there's going to be a few image galleries (for example, one for characters) where the user clicks different thumbnails and a span with text descriptions and large images are reve...

Concatenating records in a single column without looping?

I have a table with 1 column of varchar values. I am looking for a way to concatenate those values into a single value without a loop, if possible. If a loop is the most efficient way of going about this, then I'll go that way but figured I'd ask for other options before defaulting to that method. I'd also like to keep this inside of ...

Is `Delete From Join` Standard SQL?

Among other questions, this one asked how to delete from a join. My question: How much of this is standard SQL? On which databases would this actually work (most notably for me would be Oracle, MySQL and SQLServer)? ...