Search Results

Search found 36111 results on 1445 pages for 'mysql update'.

Page 66/1445 | < Previous Page | 62 63 64 65 66 67 68 69 70 71 72 73  | Next Page >

  • Cannot execute "LOAD DATA LOCAL INFILE" Mysql query in Rails after a connection reconnection

    - by Ngan
    On Rails 2.3.8 (but I think Rails 3 might have this issue as well, not sure): I get an error when trying to execute a LOAD DATA LOCAL INFILE query after reconnecting to a database. I have a process that parses a file that can potentially take a bit of time. During the parsing, Mysql closes the connection due to timeout. This is fine, I do a ActiveRecord::Base.verify_active_connections! and I get the connection back (I do this in several places through my app). However, running a LOAD DATA LOCAL INFILE statement, I get this error: Mysql::Error: The used command is not allowed with this MySQL version It's not a permission issue, I know that for sure. Check out my test in console: ActiveRecord::Base.connection.execute("LOAD DATA LOCAL INFILE '/tmp/test.infile' INTO TABLE users") [Sat Jan 08 00:09:29 2011] (9990) SQL (1.7ms) LOAD DATA LOCAL INFILE '/tmp/test.infile' INTO TABLE users => nil > ActiveRecord::Base.connection.disconnect! => #<Mysql:0x104c6f890> > ActiveRecord::Base.verify_active_connections! [Sat Jan 08 00:09:58 2011] (9990) SQL (0.2ms) SET SQL_AUTO_IS_NULL=0 => {...connection stuff...} > ActiveRecord::Base.connection.execute("LOAD DATA LOCAL INFILE '/tmp/test.infile' INTO TABLE users") [Sat Jan 08 00:10:00 2011] (9990) SQL (0.0ms) Mysql::Error: The used command is not allowed with this MySQL version: LOAD DATA LOCAL INFILE '/tmp/test.infile' INTO TABLE users ActiveRecord::StatementInvalid: Mysql::Error: The used command is not allowed with this MySQL version: LOAD DATA LOCAL INFILE '/tmp/test.infile' INTO TABLE users from ~/gems/activerecord-2.3.8/lib/active_record/connection_adapters/abstract_adapter.rb:221:in `log' from ~/gems/activerecord-2.3.8/lib/active_record/connection_adapters/mysql_adapter.rb:323:in `execute' from (irb):6 I am able to do other queries like SELECT and whatnot, and I will get the correct result. It's just this one that giving me the error. I even tested this with a fresh rails app. You'll notice that I am able to do the exact same query before the disconnect. Thanks for the help!

    Read the article

  • Is it possible to combine these 3 mySQL queries?

    - by Greenie
    I know the $downloadfile - and I want the $user_id. By trial and error I found that this does what I want. But it's 3 separate queries and 3 while loops. I have a feeling there is a better way. And yes, I only have a very little idea about what I'm doing :) $result = pod_query("SELECT ID FROM wp_posts WHERE guid LIKE '%/$downloadfile'"); while ($row = mysql_fetch_assoc($result)) { $attachment = $row['ID']; } $result = pod_query("SELECT pod_id FROM wp_pods_rel WHERE tbl_row_id = '$attachment'"); while ($row = mysql_fetch_assoc($result)) { $pod_id = $row['pod_id']; } $result = pod_query("SELECT tbl_row_id FROM wp_pods_rel WHERE tbl_row_id = '$pod_id' AND field_id = '28'"); while ($row = mysql_fetch_assoc($result)) { $user_id = $row['pod_id']; }

    Read the article

  • World's Most Challening MySQL SQL Query (least I think so...)

    - by keruilin
    Whoever answers this question can claim credit for solving the world's most challenging SQL query, according to yours truly. Working with 3 tables: users, badges, awards. Relationships: user has many awards; award belongs to user; badge has many awards; award belongs to badge. So badge_id and user_id are foreign keys in the awards table. The business logic at work here is that every time a user wins a badge, he/she receives it as an award. A user can be awarded the same badge multiple times. Each badge is assigned a designated point value (point_value is a field in the badges table). For example, BadgeA can be worth 500 Points, BadgeB 1000 Points, and so on. As further example, let's say UserX won BadgeA 10 times and BadgeB 5 times. BadgeA being worth 500 Points, and BadgeB being worth 1000 Points, UserX has accumulated a total of 10,000 Points ((10 x 500) + (5 x 1000)). The end game here is to return a list of top 50 users who have accumulated the most badge points. Can you do it?

    Read the article

  • How to make #include <mysql.h> work?

    - by symfony
    I'm building an open source project from source, and it need to include <mysql.h>: #if USE_MYSQL #include <mysql.h> #endif and the compilor reports: mysql.h no such file or directory MySQL is yet another greater open source project,what do I need to do to make it work?

    Read the article

  • How to return the value from MySql Stored Proc ??

    - by karthik
    I am using the below storedproc to generate the Insert statements of a specified table It is build-ed without any errors. Now i want to return the result set in "V_string" as output of the SP DELIMITER $$ DROP PROCEDURE IF EXISTS `demo`.`InsertGenerator` $$ CREATE DEFINER=`root`@`localhost` PROCEDURE `InsertGenerator`() SWL_return: BEGIN -- SQLWAYS_EVAL# to retrieve column specific information -- SQLWAYS_EVAL# table DECLARE v_string NATIONAL VARCHAR(3000); -- SQLWAYS_EVAL# first half -- SQLWAYS_EVAL# tement DECLARE v_stringData NATIONAL VARCHAR(3000); -- SQLWAYS_EVAL# data -- SQLWAYS_EVAL# statement DECLARE v_dataType NATIONAL VARCHAR(1000); -- SQLWAYS_EVAL# -- SQLWAYS_EVAL# columns DECLARE v_colName NATIONAL VARCHAR(50); DECLARE NO_DATA INT DEFAULT 0; DECLARE cursCol CURSOR FOR SELECT column_name,data_type FROM `columns` -- WHERE table_name = v_tableName; WHERE table_name = 'tbl_users'; DECLARE CONTINUE HANDLER FOR SQLEXCEPTION BEGIN SET NO_DATA = -2; END; DECLARE CONTINUE HANDLER FOR NOT FOUND SET NO_DATA = -1; OPEN cursCol; SET v_string = CONCAT('INSERT ',v_tableName,'('); SET v_stringData = ''; SET NO_DATA = 0; FETCH cursCol INTO v_colName,v_dataType; IF NO_DATA <> 0 then -- NOT SUPPORTED print CONCAT('Table ',@tableName, ' not found, processing skipped.') close cursCol; LEAVE SWL_return; end if; WHILE NO_DATA = 0 DO IF v_dataType in('varchar','char','nchar','nvarchar') then SET v_stringData = CONCAT(v_stringData,'SQLWAYS_EVAL# ll(',v_colName,'SQLWAYS_EVAL# ''+'); ELSE if v_dataType in('text','ntext') then -- SQLWAYS_EVAL# -- SQLWAYS_EVAL# else SET v_stringData = CONCAT(v_stringData,'SQLWAYS_EVAL# ll(cast(',v_colName,'SQLWAYS_EVAL# 00)),'''')+'''''',''+'); ELSE IF v_dataType = 'money' then -- SQLWAYS_EVAL# doesn't get converted -- SQLWAYS_EVAL# implicitly SET v_stringData = CONCAT(v_stringData,'SQLWAYS_EVAL# y,''''''+ isnull(cast(',v_colName,'SQLWAYS_EVAL# 0)),''0.0000'')+''''''),''+'); ELSE IF v_dataType = 'datetime' then SET v_stringData = CONCAT(v_stringData,'SQLWAYS_EVAL# time,''''''+ isnull(cast(',v_colName, 'SQLWAYS_EVAL# 0)),''0'')+''''''),''+'); ELSE IF v_dataType = 'image' then SET v_stringData = CONCAT(v_stringData,'SQLWAYS_EVAL# ll(cast(convert(varbinary,',v_colName, 'SQLWAYS_EVAL# 6)),''0'')+'''''',''+'); ELSE SET v_stringData = CONCAT(v_stringData,'SQLWAYS_EVAL# ll(cast(',v_colName,'SQLWAYS_EVAL# 0)),''0'')+'''''',''+'); end if; end if; end if; end if; end if; SET v_string = CONCAT(v_string,v_colName,','); SET NO_DATA = 0; FETCH cursCol INTO v_colName,v_dataType; END WHILE; END $$ DELIMITER ;

    Read the article

  • Can you reuse a mysql result set in PHP?

    - by MarathonStudios
    I have a result set I pull from a large database: $result = mysql_query($sql); I loop through this recordset once to pull specific bits of data and get averages using while($row = mysql_fetch_array($result)). Later in the page, I want to loop through this same recordset again and output everything - but because I used the recordset earlier, my second loop returns nothing. I finally hacked around this by looping through a second identical recordset ($result2 = mysql_query($sql);), but I hate to make the same SQL call twice. Any way I can loop through the same dataset multiple times?

    Read the article

  • Can not set password for mysql server in cent os 6.2

    - by HarshanaD
    I have installed mysql and then mysql-server. Then i start the mysql demon and follow below steps, # chkconfig --level 2345 mysqld on # mysqladmin -u root password testpassword But i can not set the password because it gives me the below error, Access denied for user root@localhost (using password: no) I logged in as root user and perform those steps. I even uninstalled mysql server and reinstalled but same problem occurred.

    Read the article

  • How to order by results from 2 seperate tables in PHP and MySQL.

    - by Vafello
    I am trying to output results of 2 sql queries to one JSON file. The problem is that I would like to order them ascending by distance which is the result of equation that takes homelat and homelon from the users table and lat, lng from locations table.(basically it takes lattitude and longitude of one point and another and computes the distance between these points). Is it possible to take some parameters from both select queries, compute it and output the result in ascending order? $wynik = mysql_query("SELECT homelat, homelon FROM users WHERE guid='2'") or die(mysql_error()); ; $query = "SELECT * FROM locations WHERE timestamp"; $result = map_query($query); $points = array(); while ($aaa = mysql_fetch_assoc($wynik)) { while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) { array_push($points, array('name'=>$row['name'], 'lat'=>$row['lat'], 'lng'=>$row['lng'], 'description'=>$row['description'], 'eventType'=>$row['eventType'], 'date'=>$row['date'], 'isotime'=>date('c', ($row['timestamp'])), 'homelat'=>$aaa['homelat'], 'homelon'=>$aaa['homelon'])); } echo json_encode(array("Locations"=>$points));

    Read the article

  • MySql selecting default value if there are no result?

    - by Kenan
    i'm having 2 tables: members and comments. I select all members, and then join comments. But in comments I'm selecting some SUM of points, and if user never commented, I can't get that user in listing?! So how to select default value for SUM, or some other solution: SELECT c.comment_id AS item_id, m.member_id AS member_id, m.avatar, SUM(c.vote_value) AS vote_value, SUM(c.best) AS best, SUM(c.vote_value) + SUM(c.najbolji)*10 AS total FROM members m LEFT JOIN comments c ON m.member_id = c.author_id GROUP BY c.author_id ORDER BY m.member_id DESC LIMIT {$sql_start}, {$sql_pokazi}

    Read the article

  • mysql query trying to search by alias involving CASES and aggregate functions UGH!

    - by dqhendricks
    I have two tables left joined. The query is grouped by the left table's ID column. The right table has a date column called close_date. The problem is, if there are any right table records that have not been closed (thus having a close_date of 0000-00-00), then I do not want any of the left table records to be shown, and if there are NO right table records with a close_date of 0000-00-00, I would like only the right table record with the MAX close date to be returned. So for simplicity sake, let's say the tables look like this: Table1 id 1 2 Table2 table1_id | close_date 1 | 0000-00-00 1 | 2010-01-01 2 | 2010-01-01 2 | 2010-01-02 I would like the query to only return this: Table1.id | Table2.close_date 2 | 2010-01-02 I tried to come up with an answer using aliased CASES and aggregate functions, but I could not search by the result, and I was attempting not to make a 3 mile long query to solve the problem. I looked through a few of the related posts on here, but none seem to meet the criteria of this particular case. Any pushes in the right direction would be greatly appreciated. Thanks!

    Read the article

  • How do you DELETE rows in a mysql table that have a field IN the results of another query?

    - by user354825
    here's what the statement looks like: DELETE FROM videoswatched vw2 WHERE vw2.userID IN ( SELECT vw.userID FROM videoswatched vw JOIN users u ON vw.userID=u.userID WHERE u.companyID = 1000 GROUP BY userID ) that looks decent to me, and the SELECT statement works on its own (producing rows with a single column 'userID'. basically, i want to delete entries in the 'videoswatched' table where the userID in the videoswatched entry, after joining to the users table, is found to have companyID=1000. how can i do this without getting the error in my sql syntax? it says the error is near: vw2 WHERE vw2.userID IN ( SELECT vw.userID FROM videoswatched vw JOIN users u and on line 1. thanks!

    Read the article

  • Need help with 2 MySql Queries. Join vs Subqueries.

    - by BugBusterX
    I have 2 tables: user: id, name message: sender_id, receiver_id, message, read_at, created_at There are 2 results I need to retrieve and I'm trying to find the best solution. I have included queries that I'm using in the very end. I need to retrieve a list of users, and also with each user have information available whether there are any unread messages from each user (them as sender, me as receiver) and whether or not there are any read messages between us ( they send I'm receiver or I send they are receivers) I need Same as above, but only those members where there has been any messaging between us, sorted by unread first, then by last message received. Can you advise please? Should this be done with joins or subqueries? In first case I do not need the count, I just need to know whether or not there is at least one unread message. I'm posting code and my current queries, please have a look when you get a chance: BTW, everything is the way I want in fist query. My concern is: In second query I would like to order by messages.created_at, but I dont think I can do that with grouping? And also I dont know if this approach is the most optimized and fast. CREATE TABLE `user` ( `id` bigint(20) NOT NULL AUTO_INCREMENT, `name` varchar(255) NOT NULL, PRIMARY KEY (`id`) ) INSERT INTO `user` VALUES (1,'User 1'),(2,'User 2'),(3,'User 3'),(4,'User 4'),(5,'User 5'); CREATE TABLE `message` ( `id` bigint(20) NOT NULL AUTO_INCREMENT, `sender_id` bigint(20) DEFAULT NULL, `receiver_id` bigint(20) DEFAULT NULL, `message` text, `read_at` datetime DEFAULT NULL, `created_at` datetime NOT NULL, PRIMARY KEY (`id`) ) INSERT INTO `message` VALUES (1,3,1,'Messge',NULL,'2010-10-10 10:10:10'),(2,1,4,'Hey','2010-10-10 10:10:12','2010-10-10 10:10:11'),(3,4,1,'Hello','2010-10-10 10:10:19','2010-10-10 10:10:15'),(4,1,4,'Again','2010-10-10 10:10:25','2010-10-10 10:10:21'),(5,3,1,'Hiii',NULL,'2010-10-10 10:10:21'); SELECT u.*, m_new.id as have_new, m.id as have_any FROM user u LEFT JOIN message m_new ON (u.id = m_new.sender_id AND m_new.receiver_id = 1 AND m_new.read_at IS NULL) LEFT JOIN message m ON ((u.id = m.sender_id AND m.receiver_id = 1) OR (u.id = m.receiver_id AND m.sender_id = 1)) GROUP BY u.id SELECT u.*, m_new.id as have_new, m.id as have_any FROM user u LEFT JOIN message m_new ON (u.id = m_new.sender_id AND m_new.receiver_id = 1 AND m_new.read_at IS NULL) LEFT JOIN message m ON ((u.id = m.sender_id AND m.receiver_id = 1) OR (u.id = m.receiver_id AND m.sender_id = 1)) where m.id IS NOT NULL GROUP BY u.id

    Read the article

  • MySQL - Limit a left join to the first date-time that occurs?

    - by John M
    Simplified table structure (the tables can't be merged at this time): TableA: dts_received (datetime) dts_completed (datetime) task_a (varchar) TableB: dts_started (datetime) task_b (varchar) What I would like to do is determine how long a task took to complete. The join parameter would be something like ON task_a = task_b AND dts_completed < dts_started The issue is that there may be multiple date-times that occur after the dts_completed. How do I create a join that only returns the first tableB-datetime that occurs after the tableA-datetime?

    Read the article

  • Mysql: how do I make an exact working copy of a table?

    - by epo
    I am working on a restructuring of a legacy database and its associated applications. To keep old and new working in parallel I have created a development database and copied the tables of interest to it, e.g. create database devdb; drop table if exists devdb.tab1; CREATE TABLE devdb.tab1 like working.tab1; insert into devdb.tab1 select * from working.tab1; Having done this I notice that triggers affecting tab1 have not been copied over. Is there any way in which I can produce a working copy of tab1, i.e. data, permissions, triggers, everything?

    Read the article

  • MYSQL autoincrement a column or just have an integer, difference?

    - by David19801
    Hi, If I have a column, set as primary index, and set as INT. If I don't set it as auto increment and just insert random integers which are unique into it, does that slow down future queries compared to autincrementing? Does it speed things up if I run OPTIMIZE on a table with its primary and only index as INT? (assuming only 2 columns, and second column is just some INT value) (the main worry is the upper limit on the autoincrement as theres lots of adds and deletes in my table)

    Read the article

  • How to create a MySQL query for time based elements with a 'safe window'?

    - by pj4533
    I am no SQL expert, far from it. I am writing a Rails application, and I am new at that as well. I come from a desktop programming background. My application has a table of data, one of the columns is the time at which the data was logged. I want to create a query with a 'safe window' around EACH row. By that I mean, it returns the first row, then for X minutes (based on the timelogged column) it won't return any data, once X minutes is up, it will return the next row. For example: ID | TimeLogged 1 | 3/5/2010 12:01:01 2 | 3/5/2010 12:01:50 3 | 3/5/2010 12:02:03 4 | 3/5/2010 12:10:30 5 | 3/5/2010 01:30:03 6 | 3/5/2010 01:31:05 With a 'safe window' of 5 minutes I want to create a query to return: 1 | 3/5/2010 12:01:01 4 | 3/5/2010 12:10:30 5 | 3/5/2010 01:30:03 (It skipped the 12:01:50 and 12:02:03 items because they occurred within 5 minutes of the first item.) Another example, with a 'safe window' of 15 minutes I want to return: 1 | 3/5/2010 12:01:01 5 | 3/5/2010 01:30:03 Perhaps I have to just return all data and parse it myself?

    Read the article

  • BackUp MySql Database from CommandLine

    - by srk
    I am able to backup mysql database via command line by executing the below : C:\MySQL\MySQL Server 5.0\bin\mysqldump\" -uroot -ppassword sample \"D:/admindb/AAR12.sql\" But there is no DROP and CREATE database queries in my .mysql file What should i add in the syntax to get the create info to my generated .sql file ?

    Read the article

  • mysql: Can I use two "where"s? Like, "SELECT * FROM table WHERE something and something"?

    - by KeriLynn
    I have a table with my products and I'm trying to write a page that would pull bracelets with certain colors from the database. So here's what I have right now (in php): $query = "SELECT * FROM products WHERE (products.colors LIKE '%black%')"; But I only want to select rows where the value for the column "category" equals "bracelet". I've tried a few different things, but I keep getting warnings and errors. I appreciate any help you can give, thank you!

    Read the article

  • Is it possible to update from Windows 8 Enterprise to version 8.1 without having to reinstall the OS?

    - by foregon
    Today we are told that the 8.1 update, (a version which allows you to keep apps, settings, and files), is officially being rolled out worldwide. No longer will you have to do a clean OS install, to go from 8 to 8.1. But I don't see the update inside my (Enterprise's) desktop 'Windows Update' program, and furthermore, Microsoft themselves say: If you’re running [Enterprise], you can't install the free update to Windows 8.1 or Windows RT 8.1 from the Store. However they DO also say: If you installed Windows 8 using an MSDN ISO, you might be able to install Windows 8.1 using a similar ISO from MSDN But it does not specify whether this method allows seamless apps and settings-retaining upgrading or not. Is there a method for doing it (whether official or unofficial - perhaps confirmed via experience of updating with some sort of Enterprise 8.1 ISO), or is an update indeed expected for the Enterprise version via the desktop 'Windows Update' program? A further observation which may help: the page I cite refers to the 'Windows Store', which is the 'Modern UI' app store and NOT the desktop 'Windows Update' program which typically updates desktop Office and desktop Windows alike.

    Read the article

  • Late feedback

    - by Sveta Smirnova
    MySQL Community team asked me to write about Devconf 2013 few months ago. Conference was in June, 2013, but I remembered about this my promise only now: month later after my participating in MySQL Connect and Expert Troubleshooting seminar (change country to United Kingdom if you see blank page). I think it is too late for the feedback, but I still have few thoughts which I want to record.DevConf (former PHPConf) always was a place where I tried new topics. At first, because I know audience there very well and they will be bored if I repeat a story which I was telling last year, but also because it is much easier to get feedback in your own native language. But last years my habit seems started to change and I presented improved version of my 2012 MySQL Connect talk about MySQL backups. Of course, I also had a seminar with unique topic, made for this conference first time: Troubleshooting MySQL Performance with EXPLAIN and Using Performance Schema to Troubleshoot MySQL. And these topics, improved, were presented at the expert seminar. It is interesting how my habit changes and one public speaking activity interferes next one.What is good about DevConf is it forces you to create new ideas and do it really well, because audience is not forgiving at all, so they catch everything you miss or prepared not good enough. This can be bad if you want to make a marketing-style topic for free, but allows to present technical features in really good details: all these sudden discussions really help.In year 2013 Oracle had a booth at the conference and was presented by a bunch of people. Dmitry Lenev presented topic "New features of replication in MySQL 5.6" and Victoria Reznichenko worked on the booth. What was new at the conference this year is greater interest in NoSQL, scale and fast development solutions. This, unfortunately, means not so huge interest in MySQL as it was earlier. However, at the same time, "Common" track was really MySQL track: not only Oracle, but people from other companies presented about it.

    Read the article

  • Can't append to array using string field name [$] when performing update on array fields

    - by Haraldo
    rowsI am attempting to perform a mongodb update on each field in an array of records. An example schema is below: { "_id" : ObjectId("508710f16dc636ec07000022"), "summary" : "", "uid" : "ABCDEF", "username" : "bigcheese", "name" : "Name of this document", "status_id" : 0, "rows" : [ { "score" : 12, "status_id" : 0, "uid" : 1 }, { "score" : 51, "status_id" : 0, "uid" : 2 } ] } So far I have been able to perform single updates like this: db.mycollection.update({"uid":"ABCDEF","rows.uid":1}, {$set:{"rows.$.status_id":1}},false,false) However, I am struggling as to how to perform an update that will update all array records to a status_id of 1 (for instance). Below is how I imagine it should work: db.mycollection.update({"uid":"ABCDEF"}, {$set:{"rows.$.status_id":1}},false,true) However I get the error: can't append to array using string field name [$] I have tried for quite a while with no luck. Any pointers?

    Read the article

< Previous Page | 62 63 64 65 66 67 68 69 70 71 72 73  | Next Page >