Search Results

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

Page 39/747 | < Previous Page | 35 36 37 38 39 40 41 42 43 44 45 46  | Next Page >

  • Extend linq-to-sql partial class to avoid writing a property?

    - by Curtis White
    I have a linq-to-sql class. I have a property "Password" for which I want to call the underlying ASP.NET Membership provider. Thus, I do not want this property written out directly but via my own code. I basically want to create a facade/proxy for this property such that I may use the underlying membership provider or a custom stored procedure. I want to accomplish without modifying the LINQ-TO-SQL designer generated code, if at all possible.

    Read the article

  • Linq 2 Sybase ASE database? What are the options?

    - by Scott Weinstein
    I have a need to query an existing Sybase ASE database and would like to use Linq syntax for my data retrival. I don't need write access, nor do I need the full set of Linq operators, just Select(), SelectMany(), Where(), and GroupJoin() What are options are available? In particular, I'm wondering about nHibernate and building a new Linq2Sybase provider based on the IQ toolkit.

    Read the article

  • What is the difference between these 2 XML LINQ Queries?

    - by Jon
    I have the 2 following LINQ queries and I haven't quite got my head around LINQ so what is the difference between the 2 approaches below? Is there a circumstance where one approach is better than another? ChequeDocument.Descendants("ERRORS").Where(x=>(string)x.Attribute("D") == "").Count(); (from x in ChequeDocument.Descendants("ERRORS") where (string)x.Attribute("D") == "" select x).Count())

    Read the article

  • How to use LINQ for CRUD with a simple SQL table?

    - by Rob Ferno
    Every LINQ blog I found there seemed around 2 years old, I understand the syntax but need more direction on creating the SQL mapping and context classes. I just need to use LINQ for 2 SQL tables I have, nothing complicated. Do folks write the SQL mapping classes by hand for such cases or is there a decent tool for this? Can someone point me in the right direction?

    Read the article

  • MySql - Get row number on select

    - by George
    Can I run a select statement and get the row number if the items are sorted? I have a table like this: mysql> describe orders; +-------------+---------------------+------+-----+---------+----------------+ | Field | Type | Null | Key | Default | Extra | +-------------+---------------------+------+-----+---------+----------------+ | orderID | bigint(20) unsigned | NO | PRI | NULL | auto_increment | | itemID | bigint(20) unsigned | NO | | NULL | | +-------------+---------------------+------+-----+---------+----------------+ I can then run this query to get the number of orders by ID: SELECT itemID, COUNT(*) as ordercount FROM orders GROUP BY itemID ORDER BY ordercount DESC; This gives me a count of each itemID in the table like this: +--------+------------+ | itemID | ordercount | +--------+------------+ | 388 | 3 | | 234 | 2 | | 3432 | 1 | | 693 | 1 | | 3459 | 1 | +--------+------------+ I want to get the row number as well, so I could tell that itemID 388 is the first row, 234 is second, etc (essentially the ranking of the orders, not just a raw count). I know I can do this in java when I get the result set back, but I was wondering if there was a way to handle it purely in SQL.

    Read the article

  • MYSQL stored function - create function (function definition) problem using FORMAT

    - by Jason Fonseca
    Hi all, I keep receiving an error with the following code. I am trying to make a function that will format a field (content=0.0032) into a varchar/percent (content=0.32%). At the moment i'm just trying to get format to work, and it throws up an error "Error Code : 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'len);" The function definition for "Format" is "Format(X,d)" where x is the number and d is the number of decimal places to round too. It then should output a string ###,###,###.## etc. My code is as follows: DROP FUNCTION IF EXISTS percent; DELIMITER $$ CREATE /*[DEFINER = { user | CURRENT_USER }]*/ FUNCTION `auau7859_aba`.`percent`(num DOUBLE, len INT) RETURNS VARCHAR(10) DETERMINISTIC BEGIN RETURN FORMAT(num,len); END$$ DELIMITER ; Save me...Luke

    Read the article

  • Synchronize model in MySQL Workbench

    - by Álvaro G. Vicario
    After reading the documentation for MySQL Workbench I got the impression that it's possible to alter a database in the server (e.g. add a new column) and later incorporate the DDL changes into your EER diagram. At least, it has a Synchronize Model option in the Database menu. I found it a nice feature because I could use a graphic modelling tool without becoming its prisoner. In practice, when I run such tool I'm offered these options: Model Update Source ================ ====== ====== my_database_name --> ! N/A my_table_name --> ! N/A N/A --> ! my_database_name N/A --> ! my_table_name I can't really understand it, but leaving it as is I basically get: DROP SCHEMA my_database_name CREATE SCHEMA my_database_name CREATE TABLE my_table_name This is dump of the model that overwrites all remote changes in my_table_name. Am I misunderstanding the feature?

    Read the article

  • Filtering MySQL query result according to a interval of timestamp

    - by celalo
    Let's say I have a very large MySQL table with a timestamp field. So I want to filter out some of the results not to have too many rows because I am going to print them. Let's say the timestamps are increasing as the number of rows increase and they are like every one minute on average. (Does not necessarily to be exactly once every minute, ex: 2010-06-07 03:55:14, 2010-06-07 03:56:23, 2010-06-07 03:57:01, 2010-06-07 03:57:51, 2010-06-07 03:59:21 ...) As I mentioned earlier I want to filter out some of the records, I do not have specific rule to do that, but I was thinking to filter out the rows according to the timestamp interval. After I achieve filtering I want to have a result set which has a certain amount of minutes between timestamps on average (ex: 2010-06-07 03:20:14, 2010-06-07 03:29:23, 2010-06-07 03:38:01, 2010-06-07 03:49:51, 2010-06-07 03:59:21 ...) Last but not least, the operation should not take incredible amount of time, I need this functionality to be almost fast as a normal select operation. Do you have any suggestions?

    Read the article

  • how to delete duplicates in mysql using case

    - by JPro
    Right now I am using something like this to delete duplicates in mysql table : delete t2 from my_table1 as t1, my_table1 as t2 where t1.TestCase = t2.TestCase and t2.id > t1.id; say I have a structure like this : ID TestCAse Result 1 T1 PASS 2 T2 FAIL 3 T3 FAIL 4 T3 PASS now, in the above case T3 is duplicate entry, and if I use the SQL that I mentioned above, it would delete 4th row where the result is PASS, but this is the row that I want to keep and I want row 3 to get deleted which is FAIL. Any help please? Thank you.

    Read the article

  • Can MySQL Nested Select return list of results

    - by John
    Hi I want to write a mysql statement which will return a list of results from one table along with a comma separated list of field from another table. I think an example might better explain it Table 1 ======================== id First_Name Surname ---------------------- 1 Joe Bloggs 2 Mike Smith 3 Jane Doe Table 2 ======================== id Person_Id Job_id --------------------- 1 1 1 2 1 2 3 2 2 4 3 3 5 3 4 I want to return a list of people with a comma separated list of job_ids. So my result set would be id First_Name Surname job_id ------------------------------ 1 Joe Bloggs 1,2 2 Mike Smith 2 3 Jane Doe 3,4 I guess the sql would be something like select id, First_Name, Surname, (SELECT job_id FROM Table 2) as job_id from Table 1 but obviously this does not work so need to change the '(SELECT job_id FROM Table 2) as job_id' part. Hope this makes sense Thanks John

    Read the article

  • Indexing only one MySQL column value

    - by BrainCore
    I have a MySQL InnoDB table with a status column. The status can be 'done' or 'processing'. As the table grows, at most .1% of the status values will be 'processing,' whereas the other 99.9% of the values will be 'done.' This seems like a great candidate for an index due to the high selectivity for 'processing' (though not for 'done'). Is it possible to create an index for the status column that only indexes the value 'processing'? I do not want the index to waste an enormous amount of space indexing 'done.'

    Read the article

  • mysql select from a table depending on in which table the data is in

    - by user253530
    I have 3 tables holding products for a restaurant. Products that reside in the bar, food and ingredients. I use php and mysql. I have another table that holds information about the orders that have been made so far. There are 2 fields, the most important ones, that hold information about the id of the product and the type (from the bar, from the kitchen or from the ingredients). I was thinking to write the sql query like below to use either the table for bar products, kitchen or ingredients but it doesn't work. Basically the second table on join must be either "bar", "produse" or "stoc". SELECT K.nume, COUNT(K.cantitate) as cantitate, SUM(K.pret) as pret, P.nume as NumeProduse FROM `clienti_fideli` as K JOIN if(P.tip,bar,produse) AS P ON K.produs = P.id_prod WHERE K.masa=18 and K.nume LIKE 'livrari-la-domiciliu' GROUP BY NumeProduse

    Read the article

  • [MYSQL] Select users who own both a dog and a cat

    - by matte
    Hi, I have this sample table: CREATE TABLE `dummy` ( `id` int(11) NOT NULL AUTO_INCREMENT, `userId` int(11) NOT NULL, `pet` varchar(50) NOT NULL, PRIMARY KEY (`id`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=7 ; INSERT INTO `dummy` (`id`, `userId`, `pet`) VALUES(1, 1, 'dog'); INSERT INTO `dummy` (`id`, `userId`, `pet`) VALUES(2, 1, 'cat'); INSERT INTO `dummy` (`id`, `userId`, `pet`) VALUES(3, 2, 'dog'); INSERT INTO `dummy` (`id`, `userId`, `pet`) VALUES(4, 2, 'cat'); INSERT INTO `dummy` (`id`, `userId`, `pet`) VALUES(5, 3, 'cat'); INSERT INTO `dummy` (`id`, `userId`, `pet`) VALUES(6, 4, 'dog'); How can I write the statements below in mysql: Retrieve all users who own both a dog and a cat Retrieve all users who own a dog or a cat Retrieve all users who own only a cat Retrieve all users who doesn't own a cat Thanks!

    Read the article

  • using check contraint in MySQL for controlling string length not working

    - by ptrn
    Dear stackoverflow, I'm tumbled with a problem! I've set up my first check constraint using MySQL, but unfortunately I'm having a problem. When inserting a row that should fail the test, the row is inserted anyway. The structure: CREATE TABLE user ( id INT UNSIGNED NOT NULL AUTO_INCREMENT, uname VARCHAR(10) NOT NULL, fname VARCHAR(50) NOT NULL, lname VARCHAR(50) NOT NULL, mail VARCHAR(50) NOT NULL, PRIMARY KEY (id), CHECK (LENGTH(fname) > 3) ); The insert statement: INSERT INTO user VALUES (null, 'user', 'Fname', 'Lname', '[email protected]'); I'm pretty sure I'm missing something basic here.

    Read the article

  • MYSQL: Error: Cannot add or update a child row: a foreign key constraint fails

    - by DalivDali
    Hi all, Using MySQL on Windows OS, and am getting an error upon attempting to create a foreign key between two tables: CREATE TABLE tf_traffic_stats ( domain_name char(100) NOT NULL, session_count int(11) NULL, search_count int(11) NULL, click_count int(11) NULL, revenue float NULL, rpm float NULL, cpc float NULL, traffic_date date NOT NULL DEFAULT '0000-00-00', PRIMARY KEY(domain_name,traffic_date)) and CREATE TABLE td_domain_name ( domain_id int(10) UNSIGNED AUTO_INCREMENT NOT NULL, domain_name char(100) NOT NULL, update_date date NOT NULL, PRIMARY KEY(domain_id)) The following statement gives me the error present in the subject line (cannot add or update a child row: a foreign key constraint fails): ALTER TABLE td_domain_name ADD CONSTRAINT FK_domain_name FOREIGN KEY(domain_name) REFERENCES tf_traffic_stats(domain_name) ON DELETE RESTRICT ON UPDATE RESTRICT Can someone point me in the right direction of what may be causing the error. I also have a foreign key referencing td_domain_name.domain_id, but I don't think this should be interfering... Appreciate it!

    Read the article

  • MySQL - Sort on a calculated value based on two dates

    - by Petter Magnusson
    I have the following problem that needs to be solved in a MySQL query: Fields info - textfield date1 - a date field date2 - a date field offset1 - a text field with a number in the first two positions, example "10-High" offset2 - a text field with a number in the first two positions, example "10-High" I need to sort the records by the calculated "sortvalue" based on the current date (today): If today=date2 then sortvalue=offset1*10+offset2*5+1000 else sortvalue=offset1*10+offset2*5 I have quite good understanding of basic SQL with joins etc, but this I am not even sure if its possible...if it helps I could perhaps live with a single formula giving the same sort of effect as the IFs do....ie. before date1 = low value, after date2 = high value... Rgds PM

    Read the article

  • Searching a table MySQL & PHP.

    - by S1syphus
    I want to be able to search through a MySQL table using values from a search string, from the url and display the results as an XML output. I think I have got the formatting and declaring the variables from the search string down. The issue I have is searching the entire table, I've looked over SO for previous answers, and they all seem to have to declare each column in the table to search through. So for example my database layout is as follows: **filesindex** -filename -creation -length -wall -playlocation First of all would the following be appropriate: $query = "SELECT * FROM filesindex WHERE filename LIKE '".$searchterm."%' UNION SELECT * FROM filesindex WHERE creation LIKE '".$searchterm."%' UNION SELECT * FROM filesindex WHERE length LIKE '".$searchterm."%' UNION SELECT * FROM filesindex WHERE wall LIKE '".$searchterm."%' UNION SELECT * FROM filesindex WHERE location LIKE '".$searchterm."%'"; Or ideally, is there an easier way that involves less hardcoding to search a table. Any ideas? Thanks

    Read the article

  • MySQL: Insert row on table2 if row in table1 exists

    - by Andrew M
    I'm trying to set up a MySQL query that will insert a row into table2 if a row in table1 exist already, otherwise it will just insert the row into table1. I need to find a way to adapt the following query into inserting a row into table2 with the existing row's id. INSERT INTO table1 (host, path) VALUES ('youtube.com', '/watch') IF NOT EXISTS ( SELECT * FROM table1 WHERE host='youtube.com' AND path='/watch' LIMIT 1); Something kind of like this: INSERT ... IF NOT EXISTS(..) ELSE INSERT INTO table2 (table1_id) VALUES(row.id); Except I don't know the syntax for this.

    Read the article

  • Reversing column values in mysql command line

    - by user94154
    I have a table posts with the column published, which is either 0 (unpublished) or 1 (published). Say I want to make all the published posts into unpublished posts and all the unpublished posts into published posts. I know that running UPDATE posts SET published = 1 WHERE published = 0; UPDATE posts SET published = 0 WHERE published = 1; will end up turning all my posts into published posts. How can I run these queries in the mysql command line so that it truly "reverse" the values, as opposed to the mistake outlined above? Thanks

    Read the article

  • insert array to mysql db function

    - by ganjan
    Hi. I have an array where the keys represent each column in my database. Now I want a function that makes a mysql update query. Something like $db['money'] = $money_input + $money_db; $db['location'] = $location $query = 'UPDATE tbl_user SET '; for($x = 0; $x < count($db); $x++ ){ $query .= $db something ".=." $db something } $query .= "WHERE username=".$username." ";

    Read the article

  • MySQL Query like not returning correct results

    - by Herr Kaleun
    Hello friends, i've a MySQL query that should return some rows that have the letters Ö or Ü in it but it actually does not. The query code is this: $this->db->like('title', $text ); It's PHP CodeIgniter active query. Lets assume we have 2 rows. 1. Büm 2. Bom if i search for Bü, the 1. row has to be returned but it does not. When i search for Bo the second row gets returned successfully and when i search for B both rows are returned. How could i fix this? What may be the underlieng cause? Thanks for reading.

    Read the article

  • MySQL script to delete data in chunks until everything lower then id has been deleted

    - by Chriswede
    I need an MySQL Skript which does the following: delete chunks of the database until it has deleted all link_id's greater then 10000 exmaple: x = 10000 DELETE FROM pligg_links WHERE link_id > x and link_id < x+10000 x = x + 10000 ... So it would delete DELETE FROM pligg_links WHERE link_id > 10000 and link_id < 20000 then DELETE FROM pligg_links WHERE link_id > 20000 and link_id < 30000 until all id's less then 10000 have been removed I need this because the database is very very big (more then a gig) thank in advance

    Read the article

  • MySQL: filling empty fields with zeroes when using GROUP BY

    - by SaltLake
    I've got MySQL table CREATE TABLE cms_webstat ( ID int NOT NULL auto_increment PRIMARY KEY, TIMESTAMP_X timestamp DEFAULT CURRENT_TIMESTAMP, # ... some other fields ... ) which contains statistics about site visitors. For getting visits per hour I use SELECT hour(TIMESTAMP_X) as HOUR , count(*) AS HOUR_STAT FROM cms_webstat GROUP BY HOUR ORDER BY HOUR DESC which gives me | HOUR | HOUR_STAT | | 24 | 15 | | 23 | 12 | | 22 | 9 | | 20 | 3 | | 18 | 2 | | 15 | 1 | | 12 | 3 | | 9 | 1 | | 3 | 5 | | 2 | 7 | | 1 | 9 | | 0 | 12 | And I'd like to get following: | HOUR | HOUR_STAT | | 24 | 15 | | 23 | 12 | | 22 | 9 | | 21 | 0 | | 20 | 3 | | 19 | 0 | | 18 | 2 | | 17 | 0 | | 16 | 0 | | 15 | 1 | | 14 | 0 | | 13 | 0 | | 12 | 3 | | 11 | 0 | | 10 | 0 | | 9 | 1 | | 8 | 0 | | 7 | 0 | | 6 | 0 | | 5 | 0 | | 4 | 0 | | 3 | 5 | | 2 | 7 | | 1 | 9 | | 0 | 12 | How should I modify the query to get such result? Thanks.

    Read the article

< Previous Page | 35 36 37 38 39 40 41 42 43 44 45 46  | Next Page >