Search Results

Search found 15376 results on 616 pages for 'mysql triggers'.

Page 125/616 | < Previous Page | 121 122 123 124 125 126 127 128 129 130 131 132  | Next Page >

  • MySQL 5 left join unknown column

    - by NP
    I had the below query working in mysql 4.1, but does not in 5.0: SELECT * FROM email e, event_email ee LEFT JOIN member m on m.email=e.email WHERE ee.email_id = e.email_id The error: 1054 (Unknown column 'e.email' in 'on clause')

    Read the article

  • mysql join table - selecting the newest row

    - by cmancre
    Hi, I have the following two MySQL tables TABLE NAMES NAME_ID NAME 1 name1 2 name2 3 name3 TABLE STATUS STATUS_ID NAME_ID TIMESTAMP 1 1 2010-12-20 12:00 2 2 2010-12-20 10:00 3 3 2010-12-20 10:30 4 3 2010-12-20 14:00 I would like to select all info from table NAMES and add most recent correspondent TIMESTAMP column from table STATUS RESULT NAME_ID NAME TIMESTAMP 1 name1 2010-12-20 12:00 2 name2 2010-12-20 10:00 3 name3 2010-12-20 14:00 Am stuck on this one. How do I left join only on the newer timestamp?

    Read the article

  • What Mysql query will return this result?

    - by Lost_in_code
    I have two tables A,B which are related to each other (simplified): A: +-------+---------+ | id | type | +-------+---------+ | 1 | apple | | 2 | orange | | 3 | banana | +-------+---------+ B: +-------+---------+-----------+ | id | a_id | rank | +-------+---------+-----------+ | 1 | 1 | 0.0 | | 2 | 1 | 7.7 | | 3 | 2 | 3.3 | | 4 | 2 | 8.8 | | 5 | 2 | 1.1 | | 6 | 3 | 3.3 | | 7 | 3 | 5.5 | | 8 | 1 | 9.5 | +-------+---------+-----------+ What mysql query will return the following result? Result +-------+---------+-----------+ | id | type | rank | +-------+---------+-----------+ | 1 | apple | 9.5 | | 2 | orange | 1.1 | | 3 | banana | 5.5 | +-------+---------+-----------+

    Read the article

  • GROUP BY and SUM distinct date across 2 tables

    - by kenitech
    I'm not sure if this is possible in one mysql query so I might just combine the results via php. I have 2 tables: 'users' and 'billing' I'm trying to group summed activity for every date that is available in these two tables. 'users' is not historical data but 'billing' contains a record for each transaction. In this example I am showing a user's status which I'd like to sum for created date and deposit amounts that I would also like to sum by created date. I realize there is a bit of a disconnect between the data but I'd like to some all of it together and display it as seen below. This will show me an overview of all of the users by when they were created and what the current statuses are next to total transactions. I've tried UNION as well as LEFT JOIN but I can't seem to get either to work. Union example is pretty close but doesn't combine the dates into one row. ( SELECT created, SUM(status) as totalActive, NULL as totalDeposit FROM users GROUP BY created ) UNION ( SELECT created, NULL as totalActive, SUM(transactionAmount) as totalDeposit FROM billing GROUP BY created ) I've also tried using a date lookup table and joining on the dates but the SUM values are being added multiple times. note: I don't care about the userIds at all but have it in here for the example. users table (where status of '1' denotes "active") (one record for each user) created | userId | status 2010-03-01 | 10 | 0 2010-03-01 | 11 | 1 2010-03-01 | 12 | 1 2010-03-10 | 13 | 0 2010-03-12 | 14 | 1 2010-03-12 | 15 | 1 2010-03-13 | 16 | 0 2010-03-15 | 17 | 1 billing table (record created for every instance of a billing "transaction" created | userId | transactionAmount 2010-03-01 | 10 | 50 2010-03-01 | 18 | 50 2010-03-01 | 19 | 100 2010-03-10 | 89 | 55 2010-03-15 | 16 | 50 2010-03-15 | 12 | 90 2010-03-22 | 99 | 150 desired result: created | sumStatusActive | sumStatusInactive | sumTransactions 2010-03-01 | 2 | 1 | 200 2010-03-10 | 0 | 1 | 55 2010-03-12 | 2 | 0 | 0 2010-03-13 | 0 | 0 | 0 2010-03-15 | 1 | 0 | 140 2010-03-22 | 0 | 0 | 150 Table dump: CREATE TABLE IF NOT EXISTS `users` ( `created` date NOT NULL, `userId` int(11) NOT NULL, `status` smallint(6) NOT NULL ) ENGINE=MyISAM DEFAULT CHARSET=latin1; INSERT INTO `users` (`created`, `userId`, `status`) VALUES ('2010-03-01', 10, 0), ('2010-03-01', 11, 1), ('2010-03-01', 12, 1), ('2010-03-10', 13, 0), ('2010-03-12', 14, 1), ('2010-03-12', 15, 1), ('2010-03-13', 16, 0), ('2010-03-15', 17, 1); CREATE TABLE IF NOT EXISTS `billing` ( `created` date NOT NULL, `userId` int(11) NOT NULL, `transactionAmount` int(11) NOT NULL ) ENGINE=MyISAM DEFAULT CHARSET=latin1; INSERT INTO `billing` (`created`, `userId`, `transactionAmount`) VALUES ('2010-03-01', 10, 50), ('2010-03-01', 18, 50), ('2010-03-01', 19, 100), ('2010-03-10', 89, 55), ('2010-03-15', 16, 50), ('2010-03-15', 12, 90), ('2010-03-22', 99, 150);

    Read the article

  • Efficiently store last X items in an MySQL Database

    - by Saif Bechan
    I want to store the last 3 items in an MySQL database in an efficient way. So when the 4th item is stored the first should be deleted. The way I do this not is first run a query getting the items. Than check what I should do then insert/delete. There has to be a better way to do this. Any suggestions?

    Read the article

  • Conditional sorting in MySQL?

    - by serg555
    I have "tasks" table with 3 fields: date priority (0,1,2) done (0,1) What I am trying to achieve is with the whole table sorted by done flag, tasks that are not done should be sorted by priority, while tasks that are done should be sorted by date: Select * from tasks order by done asc If done=0 additionally order by priority desc If done=1 additionally order by date desc Is it possible to do this in MySQL without unions? Thanks.

    Read the article

  • binlog_format = STATEMENT and CURRENT_TIMESTAMP with MySQL replication

    - by xma
    Hi, can a MySQL slave instance have different row values for the same ID when binlog_format is set to STATEMENT and we insert something like: insert into foo values(CURRENT_TIMESTAMP) As I understand it, the slave read the SQL statement and execute it thus, if the replication is lagging, could lead to differences for the same row. Right or wrong ? How can I avoid this situation ? Thank you.

    Read the article

  • Phpmyadmin mysql foreign key help

    - by Alan
    Hey guys i'm using phpmyadmin (php & mysql) and i'm having alot of trouble linking the tables using foreign keys. I'm getting negative values for the field countyId (which is the foriegn key). However it is linking to my other table fine and it's cascading fine. So when I go to add data there will be a drop box for the CountyId and the vlaues will look something like this, " -1 1- " Here is my alter statement, ALTER TABLE Baronies ADD FOREIGN KEY (CountyId) REFERENCES Counties (CountyId) ON DELETE CASCADE

    Read the article

  • How to sort MySQL query by two columns

    - by user334269
    The following is my DB data, how can I sorting it by sid and prev_sid with php/mysql!? sid prev_sid type 000 197 app_home 197 198 page_teach 198 218 page_teach 199 211 page_step 211 207 link 218 559 page_step 559 199 page_step Result: sid prev_sid type 000 197 app_home 197 198 page_teach 198 218 page_teach 218 559 page_step 559 199 page_step 199 211 page_step 211 207 link 000 197 198 218 559 199 199 211 207

    Read the article

  • How to store data which contains quotes in MySQL

    - by Nitz
    In one of my forms I use the rich text editor from Yahoo!. Now i want to store the data from that textarea in a MySQL database. The user can enter anything in that textarea, e.g. many double or single quotes. How can I store that data? Normally we store by adding that data in one variable and then put that in sql, but the quotes cause problems.

    Read the article

  • Python and MySQL

    - by omfgroflmao
    Is there an easy way (without downloading any plugins) to connect to a MySQL database in Python? Also, what would be the difference from calling a PHP script to retrieve the data from the database and hand it over to Python and importing one of these third-parties plugins that requires some additional software in the server.

    Read the article

  • MySQL - Update the same column twice

    - by uzioriluzan
    Hello, I need to update a column in a mysql table. If I do it in two steps as below, is the column "col" updated twice in the disk ? update table SET col=3*col, col=col+2; or is it written only once as in : update table SET col=3*col+2; Thanks

    Read the article

  • Sort MySQL result set using comparison between 2 columns of same value type

    - by Kyobul
    Hello, I have a table containing last_updated_1 and last_updated_2 columns, used respectively for text and images update time on a post. I wish I could get a result set of 10 rows based on all time last updated records contained in the 2 columns, ex. row 1 = last_updated_1 record, row 2 = last_updated_2 record, row 3 = last_updated_1 record, etc. How could I compare inside a MySQL query the both columns values, to get unique & mixed result set ? Thank you in advance for your help

    Read the article

  • summing two colums total in mysql

    - by JPro
    I want a resultset for this table : ID Number_of_posts Number_of_user 1 100 21 2 23 34 as ID Number_of_posts Number_of_user Number_of_posts_AND_Number_of_user 1 100 21 178 2 23 34 178 ----------------------------------------------- 123 55 Is it possible to get the sum of two colums as another column/ as output in mysql?

    Read the article

< Previous Page | 121 122 123 124 125 126 127 128 129 130 131 132  | Next Page >