Search Results

Search found 2601 results on 105 pages for 'condition'.

Page 12/105 | < Previous Page | 8 9 10 11 12 13 14 15 16 17 18 19  | Next Page >

  • Altering sql tables based on condition

    - by Parker
    Is there any possible way to add a row of data to only some of the tables in a database? I am not sure what parameter I could use amongst the tables to compare them to each other. Any Ideas? For Example: My database has tables that are (let's say) group A tables, and tables that are group B. I want to add a row to only the group B tables while leaving the group A tables untouched. Sorry I should have been a bit more specific. The tables that need to have a row added will change. My application monitors inventory in different store locations(each table in my database represents a store). When I need to add an item to inventory(the items are rows in the tables) I don't want to have to manually add the row to all the store tables. My problem is: Not all the tables in the database represent stores. For instance one table stores the user login data. Obviously I do not want to add the new row to this table. How do I update only the tables that represent stores?

    Read the article

  • SQL: find entries in 1:n relation that don't comply with condition spanning multiple rows

    - by milianw
    I'm trying to optimize SQL queries in Akonadi and came across the following problem that is apparently not easy to solve with SQL, at least for me: Assume the following table structure (should work in SQLite, PostgreSQL, MySQL): CREATE TABLE a ( a_id INT PRIMARY KEY ); INSERT INTO a (a_id) VALUES (1), (2), (3), (4); CREATE TABLE b ( b_id INT PRIMARY KEY, a_id INT, name VARCHAR(255) NOT NULL ); INSERT INTO b (b_id, a_id, name) VALUES (1, 1, 'foo'), (2, 1, 'bar'), (3, 1, 'asdf'), (4, 2, 'foo'), (5, 2, 'bar'), (6, 3, 'foo'); Now my problem is to find entries in a that are missing name entries in table b. E.g. I need to make sure each entry in a has at least the name entries "foo" and "bar" in table b. Hence the query should return something similar to: a_id = 3 is missing name "bar" a_id = 4 is missing name "foo" and "bar" Since both tables are potentially huge in Akonadi, performance is of utmost importance. One solution in MySQL would be: SELECT a.a_id, CONCAT('|', GROUP_CONCAT(name ORDER BY NAME ASC SEPARATOR '|'), '|') as names FROM a LEFT JOIN b USING( a_id ) GROUP BY a.a_id HAVING names IS NULL OR names NOT LIKE '%|bar|foo|%'; I have yet to measure the performance tomorrow, but severly doubt it's any fast for tens of thousand of entries in a and thrice as many in b. Furthermore we want to support SQLite and PostgreSQL where to my knowledge the GROUP_CONCAT function is not available. Thanks, good night.

    Read the article

  • Filter condition not working properly on list (C#3.0)

    - by Newbie
    I have a datatable that has many NULL or " " strings. Next I am type casting the DataTable to a list . Now if I want to filter those conditions on this list and get the resultant value(without NULL or String.Empty or " " records) what should I do? My code DataTableExtensions.AsEnumerable(dt).ToList().ForEach(i => { if (i[0] != null) { if ((i[0].ToString() != string.Empty)|| (i[0].ToString() != " ")) { list = dt.AsEnumerable().ToList(); } } }); But I am getting all the records. It is not getting filtered. Using C#3.0 Please help Thanks

    Read the article

  • Adding items to dictionary if condition is true, else dont - python

    - by CodeTalk
    I'm trying to take an existing process: if self.path_object is not None: dictpath = {} for path in self.path_object: self.params = path.pathval.split("?")[0] self.params = path.pathval.split("&", 2) if path.pathval.contains(self.params): out = list(map(lambda v: v.split("=")[0] +"=" + str(self.fuzz_vectors), self.params)) else: pass dictpath[path] = out print dictpath I added the sub-if/else block in, but it is failing, stating: AttributeError: 'unicode' object has no attribute 'contains' on the if block . How can I fix it? I'm simply trying to do: if the path.pathval has either ? or & in it: add to dictionary else: pass #forget about it. Thanks!

    Read the article

  • Mysql Left join with condition on column

    - by skicster
    Hi, can you help me with sql query? I have this problem: I have two tables "Join" table: Reservation_has_meal +----------------+ | id_reservation | | id_meal | | pieces | +----------------+ and table with data: Meal +-------------+ | id_meal | | name | +-------------+ Sample data for Meal: 1 | carrot 2 | potatoe 3 | cucumber Reservation_has_meal 1 | 2 | 5230 1 | 3 | 1203 How can I get this result for reservation with id_reservation=1: id_meal | id_Reservation | name | pcs | -------------------------------------------- 1 | 1 | carrot | null| 2 | 1 | potatoe | 5230| 3 | 1 | cucumber | 1203| -------------------------------------------- And result for id_reservation = 2: id_meal | id_Reservation | name | pcs | -------------------------------------------- 1 | 2 | carrot | null| 2 | 2 | potatoe | null| 3 | 2 | cucumber | null| -------------------------------------------- Thanks for advice.

    Read the article

  • Ruby: map tags into a boolean condition to get a true/false result

    - by cgyDeveloper
    I have an array of tags per item like so: item1 = ['new', 'expensive'] item2 = ['expensive', 'lame'] I also have a boolean expression as a string based on possible tags: buy_it = "(new || expensive) && !lame" How can I determine if an item matches the buying criteria based on the tags associated with it? My original thought was to do a gsub on all words in buy_it to become 'true' or 'false' based on them existing in the itemx tags array and then exec the resulting string to get a boolean result. But since the Ruby community is usually more creative than me, is there a better solution?

    Read the article

  • Need help specifying a ending while condition

    - by johnthexiii
    I have written a Python script to download all of the xkcd comic images. The only problem is I can't tell it to stop when it gets to the last one... Here is what I have so far. import re, mechanize from urllib import urlretrieve from BeautifulSoup import BeautifulSoup as bs baseUrl = "http://xkcd.com/1/" #Specify the first comic page br = mechanize.Browser() #Create a browser response = br.open(baseUrl) #Create an initial response x = 1 #Assign an initial file name while (SomeCondition): soup = bs(response.get_data()) #Create an instance of bs that contains the response data img = soup.findAll('img')[1] #Get the online file path of the image localFile = "C:\\Comics\\xkcd\\" + str(x) + ".jpg" #Come up with a local file name urlretrieve(img["src"], localFile) #Download the image file response = br.follow_link(text = "Next >") #Store the response of the next button x += 1 #Increase x by 1 print "All xkcd comics downloaded" #Let the user know the images have been downloaded Initially what I had was something like while br.follow_link(text = "Next >") != br.follow_link(text = ">|"): but by doing this I actually send skip to the last page before the script has a chance to perform the intended purpose.

    Read the article

  • Complex MySQL table select/join with pre-condition

    - by Howard
    Hello, I have the schema below CREATE TABLE `vocabulary` ( `vid` int(10) unsigned NOT NULL auto_increment, `name` varchar(255), PRIMARY KEY vid (`vid`) ); CREATE TABLE `term` ( `tid` int(10) unsigned NOT NULL auto_increment, `vid` int(10) unsigned NOT NULL default '0', `name` varchar(255), PRIMARY KEY tid (`tid`) ); CREATE TABLE `article` ( `aid` int(10) unsigned NOT NULL auto_increment, `body` text, PRIMARY KEY aid (`aid`) ); CREATE TABLE `article_index` ( `nid` int(10) unsigned NOT NULL default '0', `tid` int(10) unsigned NOT NULL default '0' ) INSERT INTO `vocabulary` values (1, 'vocabulary 1'); INSERT INTO `vocabulary` values (2, 'vocabulary 2'); INSERT INTO `term` values (1, 1, 'term v1 t1'); INSERT INTO `term` values (2, 1, 'term v1 t2 '); INSERT INTO `term` values (3, 2, 'term v2 t3'); INSERT INTO `term` values (4, 2, 'term v2 t4'); INSERT INTO `term` values (5, 2, 'term v2 t5'); INSERT INTO `article` values (1, ""); INSERT INTO `article` values (2, ""); INSERT INTO `article` values (3, ""); INSERT INTO `article` values (4, ""); INSERT INTO `article` values (5, ""); INSERT INTO `article_index` values (1, 1); INSERT INTO `article_index` values (1, 3); INSERT INTO `article_index` values (2, 2); INSERT INTO `article_index` values (3, 1); INSERT INTO `article_index` values (3, 3); INSERT INTO `article_index` values (4, 3); INSERT INTO `article_index` values (5, 3); INSERT INTO `article_index` values (5, 4); Example. Select term of a defiend vocabulary (with non-zero article index), e.g. vid=2 select a.tid, count(*) as article_count from term t JOIN article_index a ON t.tid = a.tid where t.vid = 2 group by t.tid; +-----+---------------+ | tid | article_count | +-----+---------------+ | 3 | 4 | | 4 | 1 | +-----+------------ Question: Select terms a. of a defiend vocabulary (with non-zero article index, e.g. vid=1 = term {1,2}) b. given that those terms are linked with articles which are linked with terms under vid=2, e.g. = {1}, term with tid=2 is excluded since no linkage to terms under vid=2 SQL: Any idea? Expected result: +-----+---------------+ | tid | article_count | +-----+---------------+ | 1 | 2 | +-----+---------------+

    Read the article

  • copy rows with special condition

    - by pooria_googooli
    I have a table with a lot of columns. For example I have a table with these columns : ID,Fname,Lname,Tel,Mob,Email,Job,Code,Company,...... ID column is auto number column. I want to copy all rows in this table to this table and change the company column value to 12 in this copied row. I don't want to write name all of the columns because I have a lot of table with a lot of columns. I tried this code but I had this error : declare @c int; declare @i int; select * into CmDet from CmDet; select @C= count(id) from CmDet; while @i < @C begin UPDATE CmDet SET company =12 WHERE company=11 set @i += 1 end error : Msg 2714, Level 16, State 6, Line 3 There is already an object named 'CmDet' in the database. I changed the code to this declare @c int declare @i int insert into CmDet select * from CmDet; select @C= count(id) from CmDet; while @i < @C begin UPDATE CmDet SET company =12 WHERE company=11 set @i += 1 end and I had this error : Msg 8101, Level 16, State 1, Line 3 An explicit value for the identity column in table 'CmDet' can only be specified when a column list is used and IDENTITY_INSERT is ON. What should I do ?

    Read the article

  • How to easily get the unmatched condition in mysql

    - by leivli
    I have a "server" table which has a column named 'SN' in mysql, when do query to retrive servers with some sns from 'sn1' to 'sn10000', we can: select * from server where sn in ('sn1','sn2','sn3',...'sn10000'); If there is only one sn in 'sn1'-'sn10000' which not exists in database, then the query above will retrive 9999 rows of result. The question is how can I easily get which one in 'sn1'-'sn10000' is not exists in database except the additional work, such as handling the result with shell script etc. I have an ugly sql like below can use: select * from (select 'sn1' as sn union select 'sn2' union select 'sn3' .... union select 'sn10000') as SN where not exists (select id from server where server.sn=SN.sn); Is Anyone has other better methods? Thanks.

    Read the article

  • WHERE condition accross multiple rows

    - by Chris G
    I have this table... -------------------------------------- | user_id | status | status_date | -------------------------------------- | 1 | Current | 2012-08-01 | | 1 | Referral | 2012-03-14 | | 2 | Referral | 2012-04-23 | | | | | -------------------------------------- How would I query to find a distinct user_id who has a referral date before 2012-06-30 AND either a current date of after 2012-06-30 or no current status record at all? Database is MySQL.

    Read the article

  • How to access object from array in if condition

    - by Happy
    Accesing array objects in javascript OBJ_ARRAY[j][i] = { "x1": w * i, "y1": h * j, "x2": w * (i + 1), "cell_color": "blue", "y2": h * (j + 1), "name": (i + 1 * (j * 10)) + 1, "z-index": 10, "status":isnotactive } I have this cell array and all its x1,y1 x2,y2 are generated dynamically. for eg. if want to compare OBJ_ARRAY[5][5].x110 then alert if(( OBJ_ARRAY[5][5].x1) > 10)) ; { alert("Done"); } It does not work any idea how it can be fixed?

    Read the article

  • How to find intersect rows when condition depend on some columns in one table

    - by user3695637
    Table subscribe subscriber | subscribeto (columns) 1 | 5 1 | 6 1 | 7 1 | 8 1 | 9 1 | 10 2 | 5 2 | 6 2 | 7 There are two users that have id 1 and 2. They subscribe to various user and I inserted these data to table subscribe. Column subscriber indicates who is subscriber and column subscribeto indicates who they've subscribe to. From the above table can conclude that; user id=1 subscribed to 6 users user id=2 subscribed to 3 users I want to find manual of subscription (like Facebook is manual friends) user 1 subscribe to user 5,6,7,8,9,10 user 2 subscribe to user 5,6,7 So, Manual subscription of user 1 and 2 are: 5,6,7 And I'm trying to create SQL statement.. I give you user table for my SQL statement and I think we can use only subscribe table but I can't figure out. Table user userid (columns) 1 2 3 ... ... SQL "select * from user where (select count( 1 ) from subscribe where subscriber = '1' and subscribeto = user.userid) and (select count( 1 ) from subscribe where subscriber = '2' and subscribeto = user.userid);" This SQL can work correctly, but it very slow for thousands of columns. Please provide better SQL for me, Thanks.

    Read the article

  • Merge two excel files (with the condition)

    - by chennai
    I have a form in access in which i have two text boxes which accepts two excel files with a button click. now when i click generate button an output excel file has to be generated or created based on the following conditions In one excel file i have these data : id code country count t100 gb123 india 3123 t100 gh125 UK 1258 t123 ytr15 USA 1111 t123 gb123 Germany 100 t145 gh575 india 99 t458 yt777 USA 90 In another excel file i have these data country location India delhi UK london USA wallstreet Germany frankfurt The rows can be more than what i mentioned here ... now i want to merge them according to the country. In book1 excel file for example wherever you find country india the location field delhi has to be inserted right beside the country field and it has to be done for each and every country which i mentioned in book2 excel file and the output file has to be sorted according to the count at last. For example the output file should like this id code country count Location t100 gb123 india 3123 delhi t100 gh125 UK 1258 london t123 ytr15 USA 1111 wallstreet t123 gb123 Germany 100 frankfrt t145 gh575 india 99 delhi t458 yt777 USA 90 wallstreet

    Read the article

  • RoR: Condition Always False - Why?

    - by Matt Hollingsworth
    Working in RoR 2.3.x. My quiz_results table has a row for user_id (3907) and result (0.1), and two users I'm looking at with no rows in the quiz_results table. This line keeps returining false: -if QuizResult.find_by_user_id(@user_id).present? But if I change it to anything that returns true, the next line reports an error on the * method: ="#{(QuizResult.average('score', :conditions => 'user_id = #{@user.id}') * 100).round}%" The beginning of the code is a loop: [email protected] do |user| Any ideas how to fix? Have tried unsuccessfully all day.

    Read the article

  • Only get the value if a condition is true

    - by Autolycus
    I am checking to see if element1, element 2 or element 3 exists and then add them to finalData if they exist. However if one of those dont exist or are not true then I just want to add the elements whose bool value is true! Below is my code bool hasElement1 = ( from Playlist in loaded.Descendants("Node") select Playlist.Descendants("Element1").Any() ).Single(); bool hasElement2 = ( from Playlist in loaded.Descendants("Node") select Playlist.Descendants("Element2").Any() ).Single(); bool hasElement3 = ( from Playlist in loaded.Descendants("Node") select Playlist.Descendants("Element2").Any() ).Single(); var finalData = from x in loaded.Descendants("Node") select new { Element1 = x.Descendants("Element1").First().Value, Element2 = x.Descendants("Element2").First().Value, Element3 = x.Descendants("Element3").First().Value, };

    Read the article

  • check_box_tag and find condition

    - by red
    <%= check_box_tag('videos_count')%> If this box is checked, the param will say "videos_count"="1" . In the controller I have this: videos_count = params[:videos_count] @cars = Car.paginate( :page => params[:page], :per_page => 10, :conditions => ["videos_count = ?", videos_count], when the box is checked I see the correct parameter in the server log, but the find returns all of the results instead of results with videos_count = 1.

    Read the article

  • Rails 2.3.8 Compound condition

    - by Michael Guantonio
    I have a rails query that I would like to run. The only problem that I am having is the query structure. Essentially the query looks like this queryList = model.find(:all, :conditions => [id = "id"]) #returns a query list #here is the issue compound = otherModel.find(:first, :select => "an_id", :conditions => ["some_other_id=? and an_id=?, some_other_id, an_id]) Where an_id is actually a list of ids in the query list. How can I write that in rails to basically associate a single id to a list that may contain ids...

    Read the article

  • Entering If Statement Despite Not Meeting Condition

    - by msmf14
    This is a specific problem, but I can't seem to figure out what is wrong. else if (X == 2) //move left { if (Level[X-1][Y] == 0); { cout << Level[X-1][Y] << "\n"; cout << "\n MOVING LEFT from RIGHT\n"; //PROBLEM IS HERE Level[X][Y] = 1; // block it X = X - 1; moved = 1; } } What I am doing is I am checking if Level[X-1][Y] is 1, indicating a column, so I can not move my player there. However for some reason, despite it being 1 and not 0 (as indicated by the output), the IF statement is still accessed. Any help will be appreciated.

    Read the article

  • How to break a jquery variable dynamically based on condition

    - by Adi
    I have a jquery variable which has is showing the value in the console as .. ["INCOMING", 0, "INETCALL", 0, "ISD", 31.8, "LOCAL", 197.92, "STD", 73.2] Now as per my need i have to break these values and make it like this ["INCOMING", 0],["INETCALL", 0],["ISD", 31.8],["LOCAL", 197.92],["STD", 73.2] but these values i need to make in the required formate dynamically as this is received from database. Here is my ajax call to get the values from server side.. var dbdata=""; $(document).ready(function() { $.ajax({ type: 'GET', url: 'getPieChartdata', async:false, dataType: "text", success: function(data) { dbdata=JSON.parse(data); } }); console.log(dbdata); }); Please guys help me . Thanks in advance..

    Read the article

  • How can I replace this semaphore with a monitor?

    - by Kurru
    Hi In previous question of mine, someone had meantioned that using Semaphores were expensive in C# compared to using a monitor. So I ask this, how can I replace the semaphore in this code with a monitor? I need function1 to return its value after function2 (in a separate thread) has been completed. I had replaced the Semaphore.WaitOne with a Monitor.Wait and the Semaphore.Release with a Monitor.PulseAll but the PulseAll was being triggered before the Wait causing the program to hang. Any idea how to avoid that race condition? Semaphore semaphore = new Semaphore(0,1); byte b; public byte Function1() { // new thread starting in Function2; semaphore.WaitOne(); return b; } public void Function2() { // do some thing b = 0; semaphore.Release(); }

    Read the article

  • Install a file which should be removed only on real uninstall and never overwritten

    - by Viv Coco
    When I install my application, along with the binaries, a conf file is installed that the user can change as he needs (it's actually the user data file). I would like this file to not be overwritten or deleted when a repair, upgrade, modify happens and it should be deleted only when a real uninstall happens. In other words: this conf file is installed along with the binaries and should never be touched again (overwritten/deleted) until a real uninstall happens (not repairs, modifies, upgrades) in which case it should be deleted. So I was thinking of doing: <Component Id="aaa.cfg" Guid="GUID"> <File Id="aaa.cfg" Source="aaa.cfg" KeyPath="yes" /> </Component> But I don't know how could I condition the component so that: 1) the component to be removed only on a real uninstall - not upgrades, repairs, modifies? 2) the file should in no case be overwritten if already exists. Thx, Viv

    Read the article

< Previous Page | 8 9 10 11 12 13 14 15 16 17 18 19  | Next Page >