Search Results

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

Page 142/616 | < Previous Page | 138 139 140 141 142 143 144 145 146 147 148 149  | Next Page >

  • MySQL Integer vs DateTime index

    - by David Kuridža
    Let me start by saying I have looked at many similar questions asked, but all of them relate to Timestamp and DateTime field type without indexing. At least that is my understanding. As we all know, there are certain advantages when it comes to DateTime. Putting them aside for a minute, and assuming table's engine is InnoDB with 10+ million records, which query would perform faster when criteria is based on: DateTime with index int with index In other words, it is better to store date and time as DateTime or UNIX timestamp in int? Keep in mind there is no need for any built-in MySQL functions to be used.

    Read the article

  • batch execute from mysql

    - by user3737088
    I need an interface for my web interface to bat files automatically temporarily to build and run. The contents of the file should come from a table in a MySQL database. It is so no matter what is in the table, the interface should run it. The web interface is based on the PHP version 5.5.6. Try and experiment After 3 months, I'm at the end and I have no ideas more. Has anyone an idea? Windows 2008 R2 IIS7 web server Full access EDIT: The batch files run through not only short. They sometimes run 1 week and longer.

    Read the article

  • foreach invalid argument supplied and mysql fetch array issue

    - by La Myse
    i have this code which i use to print some fields from the database. My problem is that i get this error about foreach invalid argument supplied and a mysql fetch array problem. The code is this: foreach( $checked1 as $key => $value){ echo "<th> $value </th>"; } echo "</tr></thead>"; while($row = mysql_fetch_array($result)){ Where $checked1 is an array $checked1 = $_POST['checkbox']; What's the problem here? Thanks..

    Read the article

  • MySQL column names and aliases

    - by user329820
    hi, I have read that after select we use column-names but I have found a statement that was like this: SELECT 'A' FROM T WHERE A = NULL; would you lease help me? thanks (A is a column- name here?) my DBMS is MySQL EDITED : the exact question is this that: Will the above statement produce a row (select all that apply)? Notice that ANSI_NULLS is OFF. I want to know that the above statement will work? because some of you said that we should write IS NULL instead of =null

    Read the article

  • Order mysql results without identifier

    - by Alex Crooks
    Usually I would have a table field called ID on auto increment. That way I could order using this field etc. However I have no control over the structure of a table, and wondered how to get the results in reverse order to default. I'm currently using $q = mysql_query("SELECT * FROM ServerChat LIMIT 15"); However like I said there is no field I can order on, so is there a way to tell mysql to reverse the order it gets the results? I.e last row to first row instead of the default.

    Read the article

  • MySQL query with JOINS and GROUP BY

    - by user1854049
    I'm building a MySQL query but I can't seem to get it right. I have four tables: - customers - orders - sales_rates - purchase_rates There is a 1:n relation 'customernr' between customers and orders. There is a 1:n relation 'ordernr' between orders and sales_rates. There is a 1:n relation 'ordernr' between orders and purchase_rates. What I would like to do is produce an output of all customers with their total purchase and sales amounts. So far I have the following query. SELECT c.customernr, c.customer_name, SUM(sr.sales_price) AS sales_price, SUM(pr.purchase_price) AS purchase_price FROM orders o, customers c, sales_rates sr, purchase_rates pr WHERE o.customernr = c.customernr AND o.ordernr = sr.ordernr AND o.ordernr = pr.ordernr GROUP BY k.bedrijfsnaam The result of the sales_price and purchase_price is far too high. I seem to be getting double counts. What am I doing wrong? Is it possible to perform this in a single query? Thank for your response!

    Read the article

  • Optimizing MySQL queries with IN operator

    - by Arkadiusz Kondas
    I have a MySQL database with a fairly large table where the products are. Each of them has its own id and categoryId field where there is a category id belongs to this product. Now I have a query that pulls out products from given categories such as: SELECT * FROM products WHERE categoryId IN ( 1, 2, 3, 4, 5, 34, 6, 7, 8, 9, 10, 11, 12 ) Of course, come a WHERE clause and ORDER BY sort but not in this thing. Let's say that these products is 250k and the visits are over 100k per day. Under such conditions in the table slow_log registered weight of these queries with large generation time. Do you have any ideas how to optimize the given problem? Table engine is MyISAM.

    Read the article

  • MySql database design for a quiz

    - by Mark
    I'm making an online quiz with php and mysql and need a bit of help deciding how to design the database for optimal insert of questions/answers and to select questions for the quiz. The table will hold 80 questions each with 4 possible options plus the correct answer. When retrieving the questions and options from the database I will randomly select 25 questions and their options. Is it better to make a single column for all questions, options, and correct answers? For example: ID | Q | OPT1 | OPT2 | OPT3 | OPT4 | ANS Or would it be better to make a column for each individual question, option, and correct answer? For example: Q1 | Q1_OPT1 | Q1_OPT2 | Q1_OPT3 | Q1_OPT5 | Q1_ANS | Q2 | Q2_OPT1 | Q2_OPT2...

    Read the article

  • Some websites to learn about MySQL tables and creating databases (The Do's and Don'ts)

    - by redsoxmaniac
    I am venturing on making a website with a database for baseball games for an intramural league. I have made databases before, but this project seems to have many fields that will require at least 3 tables. I want to make the tables correct, so that I can sort and gather information from multiple fields properly ( such as the team table querying total goals scored ). Is there a website where there is a MySQL tutorial on do's and don'ts for making somewhat complex databases? Not intro tutorials, but more around where you get into combining multiple pieces of information correctly. Any source would be helpful, thanks!

    Read the article

  • Hibernate mysql groupe by day whith 0 entities

    - by Touhami
    I have this function i need to do that in sql (hibernate or mysql) or a java function that interpert the array of results select DAY(affaire.docCreationDate), count(affaire.docfullName) from CRMAffaireCode.AffaireClass as affaire where affaire.docfullName like 'CRMAffaire.Affaire%' and affaire.docCreationDate = '" + startDate + " 00:00:00' and affaire.docCreationDate <= '" + endDate + " 23:59:59' GROUP BY DAY(affaire.docCreationDate)" i have this entitie count in my table 2012-10-05 3 2012-10-06 0 2012-10-07 7 2012-10-08 13 2012-10-09 9 2012-10-10 0 2012-10-11 0 2012-10-12 3 the request return me this values 5 3 7 7 8 13 9 9 12 3 in this way i loose three lignes that have 0 as value, i need a request that return me this 5 3 6 0 7 7 8 13 9 9 10 0 11 0 12 3

    Read the article

  • mysql result for pagination

    - by Reteras Remus
    The query is: SELECT * FROM `news` ORDER BY `id` LIMIT ($curr_page * 5), ( ($curr_page * 5) + 5 ) Where $curr_page is a php variable which is getting a value from $_GET['page'] I want to make a pagination (5 news on each page), but I don't know why the mysql is returning me extra values. On the first page the result ok: $curr_page = 0 The query would be: SELECT * FROM `news` ORDER BY `id` LIMIT 0, 5 But on the second page, the result from the query is adding extra news, 10 instead of 5. The query on the second page: SELECT * FROM `news` ORDER BY `id` LIMIT 5, 10 Whats wrong? Why the result has 10 values instead of 5? Thank you!

    Read the article

  • Bible reference books (PHP / MySQL / Unix)

    - by Josh K
    I'm looking for some nice heavy books to liter around my desk and make it look like I'm a hard core programmer. On the occasion that I might want to look something up they will also need to be useful dependable books. I'm looking for the equivalent bible in PHP, MySQL, and Unix. Should be laid out with some chapters I can actually read, along with having an in-depth reference to that particular subject. I know that the majority of this can be found on Google, but I would prefer it in book form.

    Read the article

  • php/mysql question, retrieving information

    - by chance
    Hey SO, I have a question, pretty new at PHP and MySql but was curious is it possible to display only the most recent column to a table, from a database? I know it is possible to display a list of all information, or if you have just one column of information in your table to display that using the Here is my code for my basic script (just loads 1 column of information) I would like it to only print out the recent column i added to the table $con = mysql_connect ("localhost","username","password"); if (!$con) { die ('Could not connect:' . mysql_error()0; } mysql_select_db("db_name", $con); $result = mysql_query(Select column FROM table"); while($row = mysql_fetch_array($result)) { echo $row['column']; } mysql_close($con); * keep in mind, im not looking for someone to shoot me my code with it completed, though it would be handy, however just giving me the options of what I have to do, or what the script is called would be plentiful enough for my research, thanks!

    Read the article

  • Storing SQL in MySQL: Insert as Text?

    - by Tim F
    Hey all, Working in a team environment, each one of us has put together our own list of SQL statements that we use to help with our day to day job functions. As the case often is, there may be some redundancy with this, and we are often in need of each other's statements. To circumvent this, I'm looking to put together a small app that can be used to store and search for these SQL statements. To begin with, I'm keeping it basic, just storing and searching the statements. This may build out to be the actual execution at some point in the future, but I'm not concerning myself with this at the time. This will be built with PHP and MySQL - Should I store the SQL as text, or is there something that I need to be concerned with?

    Read the article

  • Insert a row and avoiding race condition (PHP/MySQL)

    - by justkevin
    I'm working on a multiplayer game which has a lobby-like area where players select "sectors" to enter. The lobby gateway is powered by PHP, while actual gameplay is handled by one or more Java servers. The datastore is MySQL. The happy path: A player chooses a sector and tells the lobby he'd like to enter. The lobby checks whether this is okay, including checking whether there are too many players in the sector (compares the entry count in sector assignments for that sector against the sector's max_players value). The player is added to the sector_assignments table pairing him with the sector. The player client receives a passkey that will let him connect to the appropriate game server. The race condition: If two players request access to the same sector at close to same time, I can envision a case where they are both added because there was one space free when their check was started and max players gets exceeded. Is the best solution LOCK TABLE on sector_assignments? Is there another option?

    Read the article

  • MySQL pivot tables - covert rows to columns

    - by user2723490
    This is the structure of my table: Then I run a query SELECT `date`,`index_name`,`results` FROM `mst_ind` WHERE `index_name` IN ('MSCI EAFE Mid NR USD', 'Alerian MLP PR USD') AND `time_period`='M1' and get a table like How can I convert "index_name" rows to columns like: date | MSCI EAFE Mid NR USD | Alerian MLP PR USD etc In other words I need each column to represent an index and rows to represent date-result. I understand that MySQL doesn't have pivot table functions. What is the easiest way of doing this? I've tried this code, but it generates an error: SELECT `date`, MAX(IF(index_name = 'Alerian MLP PR USD' AND `time_period`='M1', results, NULL)) AS res1, MAX(IF(index_name = 'MSCI EAFE Mid NR USD' AND `time_period`='M1', results, NULL)) AS res2 FROM `mst_ind` GROUP BY `date I need to make the conversion on the query level - not PHP. Please suggest a nice and elegant solution. Thanks!

    Read the article

  • issue with selecting 1 or 0 in mysql db

    - by jason
    I am having trouble with the following SQL statement i have had this issue before but I cant remember how i fixed the problem, I am guessing the issue with this is that mysql sees 0 as null ? Note I didnt show the first part of the Select statement as its irrelevant my sql works, its showing rows with toffline that are = to 1 as well as 0... FROM table1 AS tb1 LEFT JOIN table2 AS tb2 ON tb2.id = tb1.id2 LEFT JOIN table3 AS tb3 ON tb3.id = tb1.id3 AND tb1.toffline = 0 I have also tried AND NOT tb1.toffline = 1 also WHERE tb1.toffline = 0 all with the same result...

    Read the article

  • Mysql with innodb and serializable transaction does not (always) lock rows

    - by Tobias G.
    Hello, I have a transaction with a SELECT and possible INSERT. For concurrency reasons, I added FOR UPDATE to the SELECT. To prevent phantom rows, I'm using the SERIALIZABLE transaction isolation level. This all works fine when there are any rows in the table, but not if the table is empty. When the table is empty, the SELECT FOR UPDATE does not do any (exclusive) locking and a concurrent thread/process can issue the same SELECT FOR UPDATE without being locked. CREATE TABLE t ( id INT NOT NULL AUTO_INCREMENT PRIMARY KEY, display_order INT ) ENGINE = InnoDB; SET TRANSACTION ISOLATION LEVEL SERIALIZABLE; START TRANSACTION; SELECT COALESCE(MAX(display_order), 0) + 1 from t FOR UPDATE; .. This concept works as expected with SQL Server, but not with MySQL. Any ideas on what I'm doing wrong? EDIT Adding an index on display_order does not change the behavior.

    Read the article

  • What's the safest way to remove data from mysql? (PHP/Mysql)

    - by ggfan
    I want to allow users as well as me(the admin) to delete data in mysql. I used to have remove.php that would get $_GETs from whatever that needed to be deleted such as... remove.php?action=post&posting_id=2. But I learned that anyone can simply abuse it and delete all my data. So what's the safest way for users and me to delete information without getting all crazy and hard? I am only a beginner :) I'm not sure if I can use POSTs because there is no forms and the data isn't changing. Is sessions good? Or would there be too many with postings, user information, comments, etc. Ex: James wants to delete one of his postings(it is posting_id=5). So he clicks the remove link and that takes him to remove.php?action=post&posting_id=5.

    Read the article

  • I have a tab delimeted file that I want to convert into a mysql table

    - by user320835
    I have a tab delimeted file that I want to convert into a mysql table. there are 25 tab delimeted fields in the text file. I can get the values in when I construct the SQL statement word by word and get each value individually stated in the VALUES part but when I try to get the list as a whole it does not work. Here is the code. I couldn't figure it out. Any ideas? lines=open(path, "r").readlines() for line in lines[1:]: linex=line.strip().split("\t") linex.insert(0,'sometextindex') try: cursor.execute('INSERT INTO variants VALUES(%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s)',linex) except: print 'line number=',a,linex

    Read the article

  • Best Linux filesystem for MySQL with a 100% SELECT workload

    - by gmemon
    I have a MySQL database that contains millions of rows per table and there are 9 tables in total. The database is fully populated, and all I am doing is reads i.e., there are no INSERTs or UPDATEs. Data is stored in MyISAM tables. Given this scenario, which linux file system would work best? Currently, I have xfs. But, I read somewhere that xfs has horrible read performance. Is that true? Should I shift the database to an ext3 file system? Thanks

    Read the article

  • making mysql query using splite string?

    - by Marco
    lets say i have a group of number like (3,2,5) the normal way i use to split them and searching mysql to get value is to split them using explode in PHP EXAMPLE $string = '3,4,5'; $array = explode(',',$string); foreach($array as $value){ $query = 'SELECT ID FROM TABLE WHERE ID = "'.$value.'"'; } it work like this but it make the script extremely slow i need now if there is away to split this string into the query it self and return the result without looping with PHP ?

    Read the article

  • mySQL .NET API - Delete all data from table

    - by keynesiancross
    Hi all, I'm trying to figure out if there is an easy way to delete all the data in a table using the mySQL .NET API. The only slightly more tricky part to this is that in the C# code, the business logic can be run in both cases where there is, or isn't, data in teh table. So in some regards I almost need an If statement... Currently I am using the following code, but it doesn't seem to ever delete data... string deleteSQL = "DELETE FROM `data`.`currentData`"; MySqlCommand cmd2 = new MySqlCommand(deleteSQL, conn); Any thoughts would be much appreciated! Cheers

    Read the article

  • mySQL : using BETWEEN in table ?

    - by Meko
    I have a table that includes somestudent group name ,lesson time,day names like Schedule. I am using C# whit MYSql and I want to find which lesson is when user press button from table. I can find it like entering exact value like in table 08:30 or 10:25 , it finds. But I want to make that getting system time and checking that is it between 08:30 and 10:25 or 10:25 and 12:30 . Then I can sythat it is first lesson or it is second lesson . I have also table includes Table_Time column has 5 record like 08:20 , 10:25 , 12:20 so on. Could I use like : select Lesson_Time from mydb.clock where Lesson_Time between (current time)-30 AND (current time)+30 Or can I use between operator between two columns ? Like creating Lesson_Time_Start and Lesson_Time_End and compairing current time like Lesson_Start_Time

    Read the article

  • Why am I getting a MySQL error?

    - by John Hoffman
    Here is my query. Its intention is allow access to properties of the animals that constitute a match of two animals. The match table contains columns for animal1ID and animal2ID to store which animals constitute the match. SELECT id, (SELECT * FROM animals WHERE animals.id=matches.animal1ID) AS animal1, (SELECT * FROM users WHERE animals.id=matches.animalID) AS animal2 FROM matches WHERE id=5 However, MySQl returns this error: Operand should contain 1 column(s). Why? Is there an alternative way to do this, perhaps with a JOIN statement?

    Read the article

< Previous Page | 138 139 140 141 142 143 144 145 146 147 148 149  | Next Page >