Search Results

Search found 26283 results on 1052 pages for 'temporary table'.

Page 87/1052 | < Previous Page | 83 84 85 86 87 88 89 90 91 92 93 94  | Next Page >

  • Rails 3 Join Question for Votes Table

    - by Dex
    I have a table posts and a polymorphic table votes. The votes table looks like this: create_table :votes do |t| t.references :user # user_id t.vote # the vote value t.references :votable # votable_type and votable_id end I want to list all posts that the user has not yet voted on. Right now I'm basically taking all the posts they've already voted on and subtracting that from the entire set of posts. It works but it's not very convenient as I currently have it. def self.where_not_voted_on_by(user) sql = "SELECT P.* FROM posts P LEFT OUTER JOIN (" sql << where_voted_on_by(user).to_sql sql << ") ALREADY_VOTED_FOR ON P.id = ALREADY_VOTED_FOR.id WHERE (user_id is null)" puts sql resultset = connection.select_all(sql) results = [] resultset.each do |r| results << Post.new(r) end results end def self.where_voted_on_by(user) joins(:votes.outer).where("user_id = #{user.id}").select("posts.*, votes.user_id") end

    Read the article

  • Multiple Table Joins to Improve Performance?

    - by EdenMachine
    If I have a table structure like this: Transaction [TransID, ...] Document [DocID, TransID, ...] Signer [SignerID, ...] Signature [SigID, DocID, SignerID, ...] And the business logic is like this: Transactions can have multiple documents Documents can have multiple signatures And the same signer can have multiple signatures in multiple documents within the same transaction So, now to my actual question: If I wanted to find all the documents in a particular transaction, would it be better, performance-wise, if I also stored the TransID and the DocID in the Signer table as well so I have smaller joins. Otherwise, I'd have to join through the Signature Document Transaction Documents to get all the documents in the transaction for that signer. I think it's really messy to have that many relationships in the Signer table though and it doesn't seem "correct" to do it that way (also seems like an update nightmare) but I can see that it might be better performance for direct joins. Thoughts? TIA!

    Read the article

  • For...Next Loop Multiplication Table to Start on 0

    - by nikl91
    I have my For...Next loop with a multiplication table working just fine, but I want the top left box to start at 0 and move on from there. Giving me some trouble. dim mult mult = "<table width = ""100%"" border= ""1"" >" For row = 1 to 50 mult = mult & "<tr align = ""center"" >" For col= 1 to 20 mult = mult & "<td>" & row * col & "</td>" Next mult = mult & "</tr>" Next mult = mult & "</table>" response.write mult This is what I have so far. Any suggestions?

    Read the article

  • PHP - SQL query to get update time from table status

    - by Tribalcomm
    This is my php code (I already have a connection to the db): $array = mysql_query("SHOW TABLE STATUS FROM mytable;"); while ($array = mysql_fetch_array($result)) { $updatetime = $array['Update_time']; } echo $updatetime; I get: Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource. I am running MySQL 5.0.89 and PHP5. I do not want to add a new field to the table... I want to use the table status... Any help? Thanks!

    Read the article

  • Foreign key on table A --> B, AND foreign key on table B --> A. How is this done?

    - by unclaimedbaggage
    Hi, I have two tables - 'business' and 'business_contacts'. The business_contact table has a many-to-one relationship with the business table. Furthermore, each business has a 'primary contact' field - which I'd assume is a one-to-many relationship with the business_contacts table. The problem, of course, is that this creates a catch-22 for data insertion. Since neither field can be null, I can't insert a business_contact until I have a corresponding business, but I can't insert a business until I have a corresponding business_contact. If anyone could help me get my head around how mutual one-to-many relationships are supposed to be dealt with I'd be most appreciative. (Project being done in MySQL if it makes any difference)

    Read the article

  • write.table in R screws up header when has rownames

    - by Yannick Wurm
    Hello, check this example: > a = matrix(1:9, nrow = 3, ncol = 3, dimnames = list(LETTERS[1:3], LETTERS[1:3])) > a A B C A 1 4 7 B 2 5 8 C 3 6 9 the table displays correctly. There are two different ways of writing it to file... write.csv(a, 'a.csv') which gives as expected: "","A","B","C" "A",1,4,7 "B",2,5,8 "C",3,6,9 and write.table(a, 'a.txt') which screws up "A" "B" "C" "A" 1 4 7 "B" 2 5 8 "C" 3 6 9 indeed, an empty tab is missing.... which is a pain in the butt for downstream things. Is this a bug or a feature? Is there a workaround? (other than write.table(cbind(rownames(a), a), 'a.txt', row.names=FALSE) Cheers, yannick

    Read the article

  • how to make condition to update table ?

    - by newBie
    hi..i want to make condition to update my table if there's already same data (in the same column) inserted in the table. im using If String.ReferenceEquals(hotel, hotel) = False Then insertDatabase() Else updateDatabase() End If this is the updateDatabase() code Dim sql2 As String = "update infoHotel set nameHotel = N" & FormatSqlParam(hotel) & _ ", knownAs1 = N" & FormatSqlParam(KnownAs(0)) & _ ", knownAs2 = N" & FormatSqlParam(KnownAs(1)) & _ ", knownAs3 = N" & FormatSqlParam(KnownAs(2)) & _ ", knownAs4 = N" & FormatSqlParam(KnownAs(3)) & _ " where hotel = " & hotel & ")" the function manage to go into updateDatabase() but has some error saying "Incorrect syntax near 'Oriental'." Oriental is the data inserted in the table. is it suitable to use ReferenceEquals? im using vb.net and sql database..tq

    Read the article

  • Need advice with HTML table

    - by misha-moroshko
    I would like to code an HTML table with messages like this: The table will contain messages that will spread over first N columns (N may change). Lets call these N columns, the message area. Each message is located on X contiguous cells in the message area. X may also change. Each message has a name that contains words separated with underscores. How would you recommend to code this table in Javascript/jQuery such that: It would be easy to define a message (start cell, end cell, color, name) The name will break only after underscores (rather than in the middle of the word)

    Read the article

  • Getting a table's values into a tree

    - by Jason
    So, I have a table like such: id|root|kw1|kw2|kw3|kw4|kw5|name 1| A| B| C| D| E| F|fileA 2| A| B| | | | |fileB 3| B| C| D| E| | |fileC 4| A| B| | | | |fileD (several hundred rows...) And I need to get it into a tree like the following: *A *B -fileB -fileD *C *D *E *F -fileA *B *C *D *E -fileC I'm pretty sure the table is laid out poorly but it's what I have to live with. I've read a little about Adjacency List Model & Modified Preorder Tree Traversal but I don't think my data is laid out correctly. I think this requires a recursive function, but I'm not at all sure how to go about that. I'm open to any ideas of how to get this done even if it means extracting the data into a new table just to process this. Are there any good options available to me or any good ways to do this? (Examples are a bonus of course)

    Read the article

  • How Can I Join Two DB Tables and Return Lowest Price From Joined Table

    - by Jason
    I have two tables, the first table has the product and the second table the prices. The price table could have more than one price per product but I only want to display the lowest. But I keep getting all the prices returned and I'm having trouble figuring out how to do it. this is what I get returned in my query: SELECT * FROM products AS pr JOIN prices AS p ON pr.id = p.product_id WHERE pr.live = 1 AND p.live = 1 id product1 name description £100 id product1 name description £300 id product1 name description £200 id product2 name description £50 id product2 name description £80 id product2 name description £60 id product3 name description £222 id product3 name description £234 id product3 name description £235 but I'm after: id product1 name description £100 id product2 name description £50 id product3 name description £222 Any help would be appreciated

    Read the article

  • postgresql duplicate table names best practice

    - by veilig
    My company has a handful of apps that we deploy in the websites we build. Recently a very old app needed to be included along side a newer app and there was a conflict w/ a duplicate table name needed to be used by both apps. We are now in the process of updating an old app and there will be some DB updates. I'm curious what people consider best practice (or how do you do it) to help ensure these name collisions don't happen. I've looked at schema's but not sure if thats the right path we want to take. As the documentation prescribes, I don't want to "wire" a particular schema name into an application and if I add schema's to the user search path how would it know which table I was referring to if two schema's have the same table name. although, maybe I'm reading to much into this. Any insights or words of wisdom would be greatly appreciated!

    Read the article

  • Can't call method in model table class using Doctrine with Zend Framework

    - by Jeremy Hicks
    I'm using Doctrine with Zend Framework. For my model, I'm using a base class, the regular class (which extends the base class), and a table class. In my table class, I've created a method which does a query for records with a specific value for one of the fields in my model. When I try and call this method from my controller, I get an error message saying, "Message: Unknown method Doctrine_Table::getCreditPurchases". Is there something else I need to do to call functions in my table class? Here is my code: class Model_CreditTable extends Doctrine_Table { /** * Returns an instance of this class. * * @return object Model_CreditTable */ public static function getInstance() { return Doctrine_Core::getTable('Model_Credit'); } public function getCreditPurchases($id) { $q = $this->createQuery('c') ->where('c.buyer_id = ?', $id); return $q->fetchArray(); } } // And then in my controller method I have... $this->view->credits = Doctrine_Core::getTable('Model_Credit')->getCreditPurchases($ns->id);

    Read the article

  • asp.net mvc dataannotation different table

    - by mazhar kaunain baig
    i have a lang table which is as a foreign key in the link table , The link can be in 3 languages meaning there will be 3 rows in the link table everytime i enter the record. i am using jquery tabs to enter the records in 3 languages . ok so what architecture i should follow for validation with datannotation attributes. i am using link to sql with 2010 vs. i will be creating link class with MetadataType so how will i handle for eg link name attribute 3 times.

    Read the article

  • tablerows hover with table even/odd styled via CSS

    - by root
    even/odd styles set on tablerows but hovering of table rows don't work . CSS style : #table_even tr:hover { background-color:#fffbae!important; } /* hovering */ #table_even tr:nth-child(odd) td { background-color:#fbfbfb } /*odd*/ #table_even tr:nth-child(even) td { background-color:#e8ecee } /* even*/ HTML Codes: <table id="table_even" style="width: 100%"> <tr> <td>##</td> <td>##</td> </tr> <tr> <td>##</td> <td>##</td> </tr> <tr> <td>##</td> <td>##</td> </tr> </table> how can be solve ?

    Read the article

  • How to remove duplicate records in a table?

    - by Mason Wheeler
    I've got a table in a testing DB that someone apparently got a little too trigger-happy on when running INSERT scripts to set it up. The schema looks like this: ID UNIQUEIDENTIFIER TYPE_INT SMALLINT SYSTEM_VALUE SMALLINT NAME VARCHAR MAPPED_VALUE VARCHAR It's supposed to have a few dozen rows. It has about 200,000, most of which are duplicates in which TYPE_INT, SYSTEM_VALUE, NAME and MAPPED_VALUE are all identical and ID is not. Now, I could probably make a script to clean this up that creates a temporary table in memory, uses INSERT .. SELECT DISTINCT to grab all the unique values, TRUNCATE the original table and then copy everything back. But is there a simpler way to do it, like a DELETE query with something special in the WHERE clause?

    Read the article

  • Renamed MySQL table not renamed for INSERT queries?

    - by Austin Hyde
    After renaming one of my MySQL MyISAM tables from test_tablename to tablename, I have found that if I try to execute an INSERT (or REPLACE) query, I get the following message: 1146: Table 'dbname.test_tablename' doesn't exist I have triple-checked my database abstraction code, and verified this by running the query directly on the server. According to the MySQL server, the CREATE TABLE syntax is tablename, as expected, and when I run SHOW TABLES, it lists tablename as expected. Is there any reason for this to happen? More importantly, is there an easier way to fix this than dumping, dropping, re-creating, and reloading the table?

    Read the article

  • MySQL Locking table from Stored FUNCTION

    - by Brandon
    I have a function in a MySQL Database that determines some sync parameters for a mobile device. The function determines the last date/time the user synchronized with the database. During my sync operation I call this server side function twice. As soon as I call it the second time - the entire Sync_Records table is locked. I cannot write to it from any other connection anywhere (note, after first call, the table is not locked). I changed the function to a Procedure - and all is fine - no locking after the second call. The entire sync operation (including both calls to the function/procedure) is within a transaction. This is an InnoDb table. The function/procedure simply does two select statements. They are storing results in local variables and then returning the date time variable. I don't understand why the tables are locked. Does anyone have any ideas?

    Read the article

  • problem using default_scope on a model table

    - by DannyRe
    Hey. In my controller/index action I use the following query: @course_enrollments = current_user.course_enrollments This is what my table looks like. It is referencing a course table. The course table has a colum 'title'. create_table "course_enrollments", :force => true do |t| t.integer "user_id", :null => false t.integer "course_id", :null => false t.datetime "created_at" t.datetime "updated_at" end I want to be able to order my course_enrollments by course in my index view. Furthermore Id like to do a default_scope in my model, like this: default_scope :order => 'title asc' any suggestions? Thx for your time

    Read the article

  • Count number of empty input boxes in table row

    - by Daniel Brink
    How do you calculate the number of input boxes with no value in a table row using jquery? example: <table id="table1"> <tr class="data" id="row5"> <td><input type="text" value="20%" /></td> <td><input type="text" value="10%" /></td> <td><input type="text" value="" /></td> <td><input type="text" /></td> </tr> <table> I'm looking for answer = 2

    Read the article

  • Who deleted my sql table rows?

    - by vikasde
    I have an SQL table, from which data is being deleted. Nobody knows how the data is being deleted. I added a trigger and know the time, however no jobs are running that would delete the data. I also added a trigger whenever rows are being deleted from this table. I am then inserting the deleted rows and the SYSTEM_USER to a log table, however that doesnt help much. Is there anything better I can do to know who and how the data gets deleted? Would it be possible to get the server id or something? Thanks for any advice. Sorry: I am using SQL Server 2000.

    Read the article

  • How to insert into a table with just one IDENTITY column (SQL Server CE)

    - by Hei
    Hello I am trying to insert a value in a one IDENTITY column Table in SQL Server CE 3.5. I Tried the following: INSERT Target DEFAULT VALUES INSERT Target (ID) VALUES (DEFAULT) INSERT Target (ID) VALUES () But none of them worked. This is the SQL command I used to create the table (Using SQL Server Management Studio): CREATE TABLE Target( ID int NOT NULL IDENTITY (1, 1) PRIMARY KEY ); Microsoft help site (http://msdn.microsoft.com/en-us/library/ms174633%28SQL.90%29.aspx) mentions that DEFAULT values are not valid for identity columns however they do not mention any alternative. They mention something about uniqueidentifier and ROWGUID but I have not been able to make it work. I would appreciate any pointers on how to solve this problem or links to documentation about valid sql commands for sql server CE. Thank you

    Read the article

  • drawbacks of storing all ''things' in a central table

    - by naiquevin
    Hi, I am not sure if there is a term to describe this, but I have observed that content management systems store all kinds of data in a single table with their bare minimum properties while the meta data is stored in another table in form of key value pairs. for eg. everything (blog posts, pages, images, events etc) is stored in one table and considered as a post. I understand that this allows for abstraction and easy extensibility we are considering designing our new project this way. It is not exactly a CMS but we plan to keep adding modules to it in stages. Lets say initially there will be only posts and images on which comments can be posted. Later on we might add videos which will also have the commenting feature. what are the drawbacks of this approach ? and will it work for a requirement like ours ? Thanks

    Read the article

  • Table per subclass inheritance relationship: How to query against the Parent class without loading a

    - by Arthur Ronald F D Garcia
    Suppose a Table per subclass inheritance relationship which can be described bellow (From wikibooks.org - see here) Notice Parent class is not abstract @Entity @Inheritance(strategy=InheritanceType.JOINED) public class Project { @Id private long id; // Other properties } @Entity @Table(name="LARGEPROJECT") public class LargeProject extends Project { private BigDecimal budget; } @Entity @Table(name="SMALLPROJECT") public class SmallProject extends Project { } I have a scenario where i just need to retrieve the Parent class. Because of performance issues, What should i do to run a HQL query in order to retrieve the Parent class and just the Parent class without loading any subclass ???

    Read the article

  • Table sorter causing slow script

    - by Sarah
    Hello guys i have a problem i wish i could find a solution i created this instant chat system works fine i created this seTimeout to retrieve data when the messages exceeded an extent slow script alert started to appear when i tracked down the problem i found out that the data is retrieved in time longer than the call to setTimeout and since i use jquery table sorter don't realize that the data is a table until it is all retrieved so continuous slow script alerts are displayed till all table is retrieved.one more thing i retrieve data using an ajax request. Note: The number of rows to be retrieved is 257 rows How could i solve this problem?Any ideas .

    Read the article

  • Query to get row from one table, else random row from another

    - by Jimmy
    tblUserProfile - I have a table which holds all the Profile Info (too many fields) tblMonthlyProfiles - Another table which has just the ProfileID in it (the idea is that this table holds 2 profileids which sometimes become monthly profiles (on selection)) Now when I need to show monthly profiles, I simply do a select from this tblMonthlyProfiles and Join with tblUserProfile to get all valid info. If there are no rows in tblMonthlyProfile, then monthly profile section is not displayed. Now the requirement is to ALWAYS show Monthly Profiles. If there are no rows in monthlyProfiles, it should pick up 2 random profiles from tblUserProfile. If there is only one row in monthlyProfiles, it should pick up only one random row from tblUserProfile. What is the best way to do all this in one single query ? I thought something like this select top 2 * from tblUserProfile P LEFT OUTER JOIN tblMonthlyProfiles M on M.profileid = P.profileid ORder by NEWID() But this always gives me 2 random rows from tblProfile. How can I solve this ?

    Read the article

< Previous Page | 83 84 85 86 87 88 89 90 91 92 93 94  | Next Page >