Search Results

Search found 18661 results on 747 pages for 'linq to mysql'.

Page 45/747 | < Previous Page | 41 42 43 44 45 46 47 48 49 50 51 52  | Next Page >

  • MySQL Trigger with Update

    - by Matthew
    I'm trying to update a row when it gets updated to keep one of the columns consistant, CREATE TRIGGER user_country BEFORE UPDATE ON user_billing FOR EACH ROW BEGIN IF NEW.billing_country = OLD.billing_country AND NEW.country_id != OLD.country_id THEN SET NEW.billing_country = cms.country.country_name WHERE cms.country.country_id = NEW.country_id; END IF; END But I keep recieving error #1064, Is there a way to update a row based on another row's data when the row is getting updated?

    Read the article

  • Mysql Groupby and Orderby problem

    - by luvboy
    Here is my data structure when i try this sql select rec_id, customer_id, dc_number, balance from payments where customer_id='IHS050018' group by dc_number order by rec_id desc; something is wrong somewhere, idk I need rec_id customer_id dc_number balance 2 IHS050018 DC3 -1 3 IHS050018 52 600 Thanx

    Read the article

  • mysql PDO how to bind LIKE

    - by dmontain
    In this query select wrd from tablename WHERE wrd LIKE '$partial%' I'm trying to bind the variable '$partial%' with PDO. Not sure how this works with the % at the end. Would it be select wrd from tablename WHERE wrd LIKE ':partial%' where :partial is bound to $partial="somet" or would it be select wrd from tablename WHERE wrd LIKE ':partial' where :partial is bound to $partial="somet%" or would it be something entirely different?

    Read the article

  • MySQL : AVG of AVG impossible ?

    - by Tristan
    Hi, I want to do an average : the problem is for 1 item i'm calculating the AVG of each elements (working) but as soon as i want the GLOBAL average the average of the elements (something and foo) it doesn't work. I need to do that because i want to sort the result by the global average SELECT AVG(AVG(something)+AVG(foo)) /2 as moy ..... ORDER BY moy DESC Thanks,

    Read the article

  • MySQL Need help constructing query: join multiple tables into single row

    - by Jed Daniels
    Hello stackoverflowers, Forgive me if this question has been asked and answered, I've searched and found a few that look similar but I'm too much of a novice with SQL to adapt them to my needs. Also forgive me if I don't use the correct terminology, I know it can be annoying when someone asks a question and they don't even know enough to be able to ask for what they need. I'm helping a friend gather some data, and need to perform a query that results in a single row per record, but instead I get multiple rows. Here is an example of what I'm querying right now (simplified, hopefully not too much): SELECT * FROM `table_one` AS t1 INNER JOIN `table_two` AS t2 ON t1.id = t2.id INNER JOIN `table_three` AS t3 ON t1.id = t3.id WHERE 1 The result is: id text number 5 Subtotal 17 5 Tax 3 5 Total 20 What I need is to create a query that results in something more like this: id text number text number text number 5 subtotal 17 Tax 3 Total 20 Any assistance/guidance would be much appreciated. Thanks! --jed

    Read the article

  • displaying a group once in php mysql

    - by JPro
    I have some data like this : 1 TC1 PASS 2 TC2 FAIL 3 TC3 INCONC 4 TC1 FAIL 5 TC21 FAIL 6 TC4 PASS 7 TC3 PASS 8 TC2 FAIL 9 TC1 TIMEOUT 10 TC21 FAIL If I try the below code : <?php mysql_connect("localhost", "root", "pop") or die(mysql_error()); mysql_select_db("jpd") or die(mysql_error()); $oustanding_fails = mysql_query("select * from SELECT_PASS ") or die(mysql_error()); $resultSetArray = array(); $platform; while($row1 = mysql_fetch_array( $oustanding_fails )) { if(trim($row1['TESTCASE']) <> trim($platform)) { echo $row1['TESTCASE']."-"; $platform = $row1['TESTCASE']; } echo $row1['RESULT'] ."<br>"; } ?> to get a result like this : TC1 PASS FAIL TIMEOUT TC2 FAIL FAIL TC3 INCONC PASS TC4 PASS AND SO ON. I am unable to get the result I want. Any ideas where exactly I am making mistake? Thanks.

    Read the article

  • MySQL function: Rotate old entries to archive table

    - by confiq
    Hi, I'm looking for the function that will take rows older then X days and put it in archive table... Was thinking to make function so it will be easer to execute... something like CREATE TABLE archive_NUMBER_OF_WEEK (...); INSERT INTO archive_NUMBER_OF_WEEK SELECT * FROM content WHERE DATE < X days; DELETE * FROM content WHERE DATE < X days RENAME TABLE content TO content_backup, content_temp TO content; Will post when I finish it :)

    Read the article

  • Mysql - Help me alter this search query to get desired results

    - by sandeepan-nath
    Following is a dump of the tables and data needed to answer understand the system:- The system consists of tutors and classes. The data in the table All_Tag_Relations stores tag relations for each tutor registered and each class created by a tutor. The tag relations are used for searching classes. CREATE TABLE IF NOT EXISTS `Tags` ( `id_tag` int(10) unsigned NOT NULL auto_increment, `tag` varchar(255) default NULL, PRIMARY KEY (`id_tag`), UNIQUE KEY `tag` (`tag`), KEY `id_tag` (`id_tag`), KEY `tag_2` (`tag`), KEY `tag_3` (`tag`), KEY `tag_4` (`tag`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1; INSERT INTO `Tags` (`id_tag`, `tag`) VALUES (1, 'Sandeepan'), (2, 'Nath'), (3, 'first'), (4, 'class'), (5, 'new'), (6, 'Bob'), (7, 'Cratchit'); CREATE TABLE IF NOT EXISTS `All_Tag_Relations` ( `id_tag` int(10) unsigned NOT NULL default '0', `id_tutor` int(10) default NULL, `id_wc` int(10) unsigned default NULL, KEY `All_Tag_Relations_FKIndex1` (`id_tag`), KEY `id_wc` (`id_wc`), KEY `id_tag` (`id_tag`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1; INSERT INTO `All_Tag_Relations` (`id_tag`, `id_tutor`, `id_wc`) VALUES (1, 1, NULL), (2, 1, NULL), (3, 1, 1), (4, 1, 1), (6, 2, NULL), (7, 2, NULL), (5, 2, 2), (4, 2, 2); Following is my query:- This query searches for "first class" (tag for first = 3 and for class = 4, in Tags table) and returns all those classes such that both the terms first and class are present in the class name. SELECT wtagrels.id_wc,SUM(DISTINCT( wtagrels.id_tag =3)) AS key_1_total_matches, SUM(DISTINCT( wtagrels.id_tag =4)) AS key_2_total_matches FROM all_tag_relations AS wtagrels WHERE ( wtagrels.id_tag =3 OR wtagrels.id_tag =4 ) GROUP BY wtagrels.id_wc HAVING key_1_total_matches = 1 AND key_2_total_matches = 1 LIMIT 0, 20 And it returns the class with id_wc = 1. But, I want the search to show all those classes such that all the search terms are present in the class name or its tutor name So that searching "Sandeepan class" (wtagrels.id_tag = 1,4) or "Sandeepan Nath" also returns the class with id_wc=1. And Searching. Searching "Bob First" should not return any classes. Please modify the above query or suggest a new query, if possible using MyIsam - fulltext search, but somehow help me get the result.

    Read the article

  • Enforcing a query in MySql to use a specific index

    - by Hossein
    Hi, I have large table. consisting of only 3 columns (id(INT),bookmarkID(INT),tagID(INT)).I have two BTREE indexes one for each bookmarkID and tagID columns.This table has about 21 Million records. I am trying to run this query: SELECT bookmarkID,COUNT(bookmarkID) AS count FROM bookmark_tag_map GROUP BY tagID,bookmarkID HAVING tagID IN (-----"tagIDList"-----) AND count >= N which takes ages to return the results.I read somewhere that if make an index in which it has tagID,bookmarkID together, i will get a much faster result. I created the index after some time. Tried the query again, but it seems that this query is not using the new index that I have made.I ran EXPLAIN and saw that it is actually true. My question now is that how I can enforce a query to use a specific index? also comments on other ways to make the query faster are welcome. Thanks

    Read the article

  • mysql partitioning

    - by Yang
    just want to verify that database partition is implemented only at the database level, when we query a partitioned table, we still do our normal query, nothing special with our queries, the optimization is performed automatically when parsing the query, is that correct? e.g. we have a table called 'address' with a column called 'country_code' and 'city'. so if i want to get all the addresses in New York, US, normally i wound do something like this: select * from address where country_code = 'US' and city = 'New York' if now the table is partitioned by 'country_code', and i know that now the query will only be executed on the partition which contains country_code = US. My question is do I need to explicitly specify the partition to query in my sql statement? or i still use the previous statement and the db server will optimize it automatically? Thanks in advance!

    Read the article

  • MYSQL update query php

    - by bell
    I am trying to use an update query to change values held in a database, the new values I am trying to store are held in php variables. I'm not sure what it is I'm doing wrong. mysql_query("UPDATE user SET status='full' WHERE user_id = '$user_id'")or die(mysql_error()); thanks in advance

    Read the article

  • Get Auto Increment value with MySQL query

    - by James Simpson
    I currently have a database with over 6 million rows and growing. I currently do SELECT COUNT(id) FROM table; in order to display the number to my users, but the database is getting large and I have no need to store all of those rows except to be able to show the number. Is there a way to select the auto_increment value to display so that I can clear out most of the rows in the database? Using LAST_INSERT_ID() doesn't seem to work.

    Read the article

  • MySql SELECT AS - Append all field names

    - by jeerose
    I'd like to do something like this: SELECT table.id AS prefix_id, table.name AS prefix_name ... and have the prefix added dynamically to all field names rather than selecting them all manually (ie SELECT table.* AS prefix_* or something) Hopefully I've described that accurately. Any thoughts? Edit To be clear, the reason I'm asking is to make sure that my query result contains every column from each table I call even if there are duplicate field names. For example, I might have a table with lots of fields which means I don't want to alias all the fields manually. Further if 3 tables have a field called name my result won't contain three name results; it will have one. I want to avoid ambiguity with my column names.

    Read the article

  • A better way to build this MySQL statement with subselects

    - by Corey Maass
    I have five tables in my database. Members, items, comments, votes and countries. I want to get 10 items. I want to get the count of comments and votes for each item. I also want the member that submitted each item, and the country they are from. After posting here and elsewhere, I started using subselects to get the counts, but this query is taking 10 seconds or more! SELECT `items_2`.*, (SELECT COUNT(*) FROM `comments` WHERE (comments.Script = items_2.Id) AND (comments.Active = 1)) AS `Comments`, (SELECT COUNT(votes.Member) FROM `votes` WHERE (votes.Script = items_2.Id) AND (votes.Active = 1)) AS `votes`, `countrys`.`Name` AS `Country` FROM `items` AS `items_2` INNER JOIN `members` ON items_2.Member=members.Id AND members.Active = 1 INNER JOIN `members` AS `members_2` ON items_2.Member=members.Id LEFT JOIN `countrys` ON countrys.Id = members.Country GROUP BY `items_2`.`Id` ORDER BY `Created` DESC LIMIT 10 My question is whether this is the right way to do this, if there's better way to write this statement OR if there's a whole different approach that will be better. Should I run the subselects separately and aggregate the information?

    Read the article

  • MySQL Query Help

    - by Andy
    I need to find the category id in the products table below. However the cms_ecom_categories.id is wrapped with the & character like &12&. Is there some kind of wild card i could use to wrap around? like %cms_ecom_categories.id% ? $sql = "SELECT * FROM cms_ecom_products, cms_ecom_categories WHERE cms_ecom_products.pCategories = cms_ecom_categories.id AND cms_ecom_categories.slug = ".$page.""; Thanks to all in advance who can help.

    Read the article

  • MySQL keeps crashing OS server.. Please help adjust my.ini!

    - by TruMan1
    I have MySQL 5.0 installed on a Windows 2008 machine (3GB RAM). My server crashes on a regular basis (almost once a day) with this error: Changed limits: max_open_files: 2048 max_connections: 800 table_cache: 619 I did not use the heavy InnoDB .ini file, although I am rethinking that I should have? I am worried that big configuration changes will make my current sites stop working. What should I do? Here is my current ini settings: default-character-set=latin1 default-storage-engine=INNODB max_connections=800 query_cache_size=84M table_cache=1520 tmp_table_size=30M thread_cache_size=38 myisam_max_sort_file_size=100G myisam_sort_buffer_size=30M key_buffer_size=129M read_buffer_size=64K read_rnd_buffer_size=256K sort_buffer_size=256K innodb_additional_mem_pool_size=6M innodb_flush_log_at_trx_commit=1 innodb_log_buffer_size=3M innodb_buffer_pool_size=250M innodb_log_file_size=50M innodb_thread_concurrency=10

    Read the article

  • Getting MySQL record count with C#

    - by she hates me
    Hello, I would like to know how can I get record count of a query with C#. Here is the code that I use.. MySqlDataReader recordset = null; query = new MySqlCommand("SELECT * FROM test ORDER BY type_ID ASC", this.conn); recordset = query.ExecuteReader(); while (recordset.Read()) { result.Add(recordset["type_ID"].ToString()); } return result;

    Read the article

  • Listing mysql row entries from tags into one single row

    - by Derrick
    Hi guys, Ive got two tables, one a listings and another representing a list of tags for the listing table. In the listings table the tag ids are stored in a field called tags as 1-2-3- this has worked out very well for me regular expressions and joins to seperate and display the data, BUT... I now need to pull the titles of those tags into a single row. See below. listings table id tags 1 1-2-3- 2 4-5-6- tags table id title 1 pig 2 dog 3 cat 4 mouse 5 elephant 6 duck And what I need to produce out of the listings table is: id tags 2 mouse, elephant, duck any suggestions?

    Read the article

  • php MySQL snytax error

    - by Jacksta
    my scrip is supposed to look up contacts in a table and present thm on the screen to then be edited. however this is not this case. I am getting the error Parse error: syntax error, unexpected $end in /home/admin/domains/domain.com.au/public_html/pick_modcontact.php on line 50 NOTE: this is the last line in this script. <? session_start(); if ($_SESSION[valid] != "yes") { header( "Location: contact_menu.php"); exit; } $db_name = "testDB"; $table_name = "my_contacts"; $connection = @mysql_connect("localhost", "user", "pass") or die(mysql_error()); $db = @mysql_select_db($db_name, $connection) or die(mysql_error()); $sql = "SELECT id, f_name, l_name FROM $table_name ORDER BY f_name"; $result = @mysql_query($sql, $connection) or die(mysql_error()); $num = @mysql_num_rows($result); if ($num < 1) { $display_block = "<p><em>Sorry No Results!</em></p>"; } else { while ($row = mysql_fetch_array($result)) { $id = $row['id']; $f_name = $row['f_name']; $l_name = $row['l_name']; $option_block .= "<option value\"$id\">$l_name, $f_name</option>"; } $display_block = "<form method=\"POST\" action=\"show_modcontact.php\"> <p><strong>Contact:</strong> <select name=\"id\">$option_block</select> <input type=\"submit\" name=\"submit\" value=\"Select This Contact\"></p> </form>"; ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Modify A Contact</title> </head> <body> <h1>My Contact Management System</h1> <h2><em>Modify a Contact</em></h2> <p>Select a contact from the list below, to modify the contact's record.</p> <? echo "$display_block"; ?> <br> <p><a href="contact_menu.php">Return to Main Menu</a></p> </body> </html>

    Read the article

  • mysql query optimisation

    - by Bharanikumar
    i have around (1,049,906 total, Query took 0.0005 sec) in my x table , If i simply retrieve trying to retrive the particular field records , Its tooks hardly 6 mins , This is my query SELECT CUSTOMER_CODE FROM X_TBL ; CUSTOMER_CODE = UNIQUE THE ABOVE QUERY TOOK 6MIN , Tel me optimization tips for this , Also in some situation to search customer , i used the CUSTOMER_CODE in like , select CUSTOMER_CODE from X_TBL WHERE CUSTOMER_CODE LIKE "$KEY_WORD%" Regards Bharanikumar

    Read the article

  • Merging MySQL row entries into a single row

    - by Derrick
    I've got two tables, one for listings and another representing a list of tags for the listings table. In the listings table the tag ids are stored in a field called tags as 1-2-3-. This has worked out very well for me (regular expressions and joins to separate and display the data), but I now need to pull the titles of those tags into a single row. See below. listings table id tags 1 1-2-3- 2 4-5-6- tags table id title 1 pig 2 dog 3 cat 4 mouse 5 elephant 6 duck And what I need to produce out of the listings table is: id tags 2 mouse, elephant, duck

    Read the article

< Previous Page | 41 42 43 44 45 46 47 48 49 50 51 52  | Next Page >