Search Results

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

Page 58/1052 | < Previous Page | 54 55 56 57 58 59 60 61 62 63 64 65  | Next Page >

  • Join a single row in one table to n random rows in another

    - by Einar Egilsson
    Is it possible to make a join in SQL server that joins each row from table A to n random rows in another? For example, say I have a Customer table, a Product table and an Order table. I want to join each customer to 5 random products and insert these rows into the order table. (And each customer should be joined to 5 random rows of his own, I don't want all customers joining to the same 5 rows). Is this possible? I'm using SQL Server 2005 and it's fine if the solution is specific to that. This is a weird requirement but I'm basically making a small data generator to generate some random data.

    Read the article

  • Dynamically determining table name given field name in SQL server

    - by Salman A
    Strange situation: I am trying to remove some hard coding from my code. There is a situation where I have a field, lets say "CityID", and using this information, I want to find out which table contains a primary key called CityID. Logically, you'd say that it's probably a table called "City" but it's not... that table is called "Cities". There are some other inconsistencies in database naming hence I can never be sure if removing the string "ID" and finding out the plural will be sufficient. Note: Once I figure out that CityID refers to a table called Cities, I will perform a join to replace CityID with city name on the fly. I will appreciate if someonw can also tell me how to find out the first varchar field in a table given its name.

    Read the article

  • How to use a proprety/value table in MySQL

    - by David
    I inherited a mysql database that has a table with columns like this: object_id, property, value It holds data like this: 1,first_name,Jane 1,last_name,Doe 1,age,10 1,color,red 2,first_name,Mike 2,last_name,Smith 2,age,20 2,color,blue 3,first_name,John 3,last_name,Doe 3,age,20 3,color,red ... Basically what I want to do is treat this table as a regular table. How would I get the id numbers (or all properties) of a person who is age 20 sorted by last and than first name? So far I have: SELECT object_id FROM table WHERE property = 'age' AND value = '20' union SELECT object_id FROM table WHERE property = 'color' AND value = 'red' But I'm not sure how to go about ordering the data. Thanks

    Read the article

  • Reading directly from the Doctrine Searchable index table

    - by phidah
    I've got a Doctrine table with the Searchable behavior enabled. Whenever a record is created, an index is made in another table. I have a model called Entry and the behavior automatically created the table entry_index. My question now is: How can I - without using the search(...) methods of my model use the data from this table? I want to create a tag cloud of the words most used, and the data in the index table is exactly what I need.

    Read the article

  • sql server deadlock issue on a single table..................

    - by devendra
    I have one table let's say "xxx "in sql server 2000 . One .exe is inserting data into that table "xxx" through sql job. But once data is inserted , one stored procedure is reading the data from that "xxx table "and inserting/updating into other two tables and updating back the status into the same "xxx" table. Now, client says that multiple deadlocks are occuring on that "xxx" table . please kindly anyone sdvice me the resolution steps to be taken to resolve this deadlock issue and how to identify it step by step............. Thanks in advance..... XXX

    Read the article

  • MySQL insert at end of table

    - by Theopile
    Hello, I am using MySQL and PHP. I am having a problem with inserting a new item at the end of my table. When I insert the new item appears after the last created item, but I want it to be entered at the bottom of the table. Suppose that I have a table id=int,Primary Key and album=string and the table is: Wrath Crack The Skye Enter Shikari What would the MySQL query be if php variable $album=myAlbum was to be inserted next, at the end of the table, and with the appropriate id? Thanks

    Read the article

  • Regular expression to match any table tag

    - by keeg
    I'm trying to write a regular expression to see if a string contains any of the typical table tags: <table></table> <td></td> <th></th> <tr></tr> <thead></thead> <tfoot></tfoot> <tbody></tbody> Along with tags that may contain other attributes e.g: <table border="1"> I've come up with this so far, however, it matches <br /> tag and I'm not sure why: /<\/?[table|td|th|tr|tfoot|thead|tbody]{1,}>?/ http://www.rexfiddle.net/20Xtqka

    Read the article

  • Loading a DB table into nested dictionaries in Python

    - by Hossein
    Hi, I have a table in MySql DB which I want to load it to a dictionary in python. the table columns is as follows: id,url,tag,tagCount tagCount is the number of times that a tag has been repeated for a certain url. So in that case I need a nested dictionary, in other words a dictionary of dictionary, to load this table. Because each url have several tags for which there are different tagCounts.the code that I used is this:( the whole table is about 22,000 records ) cursor.execute( ''' SELECT url,tag,tagCount FROM wtp ''') urlTagCount = cursor.fetchall() d = defaultdict(defaultdict) for url,tag,tagCount in urlTagCount: d[url][tag]=tagCount print d first of all I want to know if this is correct.. and if it is why it takes so much time? Is there any faster solutions? I am loading this table into memory to have fast access to get rid of the hassle of slow database operations, but with this slow speed it has become a bottleneck itself, it is even much slower than DB access. and anyone help? thanks

    Read the article

  • Sort a GridView Column related to other Table

    - by Tim
    Hello, i have a GridView bound to a DataView. Some columns in the DataView's table are foreignkeys to related tables(f.e. Customer). I want to enable sorting for these columns too, but all i can do is sorting the foreignkey(fiCustomer) and not the CustomerName. I have tried this without success(" Cannot find column ERP_Customer.CustomerName "): <asp:TemplateField HeaderText="Customer" SortExpression="ERP_Customer.CustomerName" > A tried also the DataViewManager, but i've a problem to detect the table to sort: Dim viewManager As New DataViewManager(Me.dsERP) viewManager.DataViewSettings(dsERP.ERP_Charge).RowFilter = filter viewManager.DataViewSettings(dsERP.ERP_Charge).Sort = sort 'sort is the GridView's SortExpression Me.GrdCharge.DataSource = viewManager.CreateDataView(dsERP.ERP_Charge) I have to apply the sort on a distinct table of the DataViewManager, but this table would differ on the related tables. I have bound the TemplateColumns in Codebehind in RowDataBound-Event f.e.: Dim LblCustomer As Label = DirectCast(e.Row.FindControl("LblCustomer"), Label) LblCustomer.Text = drCharge.ERP_CustomerRow.CustomerName 'drCharge inherits DataRow What is the recommended way to sort a GridView on columns related to another table?

    Read the article

  • Check if row already exists, if so tell the referenced table the id

    - by flhe
    Let's assume I have a table magazine: CREATE TABLE magazine ( magazine_id integer NOT NULL DEFAULT nextval(('public.magazine_magazine_id_seq'::text)::regclass), longname character varying(1000), shortname character varying(200), issn character varying(9), CONSTRAINT pk_magazine PRIMARY KEY (magazine_id) ); And another table issue: CREATE TABLE issue ( issue_id integer NOT NULL DEFAULT nextval(('public.issue_issue_id_seq'::text)::regclass), number integer, year integer, volume integer, fk_magazine_id integer, CONSTRAINT pk_issue PRIMARY KEY (issue_id), CONSTRAINT fk_magazine_id FOREIGN KEY (fk_magazine_id) REFERENCES magazine (magazine_id) MATCH SIMPLE ON UPDATE NO ACTION ON DELETE NO ACTION ); Current INSERTS: INSERT INTO magazine (longname,shotname,issn) VALUES ('a long name','ee','1111-2222'); INSERT INTO issue (fk_magazine_id,number,year,volume) VALUES (currval('magazine_magazine_id_seq'),'8','1982','6'); Now a row should only be inserted into 'magazine', if it does not already exist. However if it exists, the table 'issue' needs to get the 'magazine_id' of the row that already exists in order to establish the reference. How can i do this? Thx in advance!

    Read the article

  • MySQL SELECT results from 1 table, but exclude results depending on another table?

    - by Brandon
    Hey, What SQL query would I have to use if I want to get the results from a table 'messages' but exclude rows that have the value in 'messages_view' where field messages.message=messages_view.id AND messages.deleted=1 AND messages_view.user=$somephpvariable In more laymen terms, I have a messages table with each message denoted by an 'id' as well as a messages_view table connected with a 'message' field. I want to get the rows in message that are not deleted (comes from messages_view) for a specific 'user'. 'deleted'=1 when the message is deleted. Here is my current SQL Query that just gets the values out of : SELECT * FROM messages WHERE ((m_to=$user_id) OR (m_to=0 AND (m_to_state='' OR m_to_state='$state') AND (m_to_city='' OR m_to_city='$city'))) Here is the layout of my tables: table: messages ---------------------------- id (INT) (auto increment) m_from (INT) <-- Represents a user id (0 = site admin) m_to (INT) <-- Represents a user id (0 = all users) m_to_state (VARCHAR) m_to_city (VARCHAR) table: messages_view ---------------------------- message (INT) <-- Corresponds to messages.id above user (INT) <-- Represents a user id deleted (INT) <-- 1 = deleted

    Read the article

  • Speed-up of readonly MyISAM table

    - by Ozzy
    We have a large MyISAM table that is used to archive old data. This archiving is performed every month, and except from these occasions data is never written to the table. Is there anyway to "tell" MySQL that this table is read-only, so that MySQL might optimize the performance of reads from this table? I've looked at the MEMORY storage engine, but the problem is that this table is so large that it would take a large portion of the servers memory, which I don't want. Hope my question is clear enough, I'm a novice when it comes to db administration so any input or suggestions are welcome.

    Read the article

  • What is prefered stratigies for cross browser and multiple styled table in CSS

    - by jitendra
    in default css what should i predefined for <table>, td, th , thead, tbody, tfoot I have to work in a project there are so many tables with different color schemes and different type of alignment like in some table , i will need to horizontally align data of cell to right, sometime left, sometime right. same thing for vertical alignment, top, bottom and middle. some table will have thin border on row , some will have thick (same with column border). Some time i want to give different background color to particular row or column or in multiple row or column. So my question is: What code should i keep in css default for all tables and how to handle table with different style using ID and classes in multiple pages. I want to do every presentational thing with css. How to make ID classes for everything using semantic naming ? Which tags related to table can be useful?

    Read the article

  • Display another field in the referenced table for multiple columns with performance issues in mind

    - by israkir
    I have a table of edge like this: ------------------------------- | id | arg1 | relation | arg2 | ------------------------------- | 1 | 1 | 3 | 4 | ------------------------------- | 2 | 2 | 6 | 5 | ------------------------------- where arg1, relation and arg2 reference to the ids of objects in another object table: -------------------- | id | object_name | -------------------- | 1 | book | -------------------- | 2 | pen | -------------------- | 3 | on | -------------------- | 4 | table | -------------------- | 5 | bag | -------------------- | 6 | in | -------------------- What I want to do is that, considering performance issues (a very big table more than 50 million of entries) display the object_name for each edge entry rather than id such as: --------------------------- | arg1 | relation | arg2 | --------------------------- | book | on | table | --------------------------- | pen | in | bag | --------------------------- What is the best select query to do this? Also, I am open to suggestions for optimizing the query - adding more index on the tables etc... EDIT: Based on the comments below: 1) @Craig Ringer: PostgreSQL version: 8.4.13 and only index is id for both tables. 2) @andrefsp: edge is almost x2 times bigger than object.

    Read the article

  • update table with information from IDirectory

    - by sue
    I have a table with 4 columns, LoginID, LastName, FirstName, Email. The data for LoginID was populated from an other table. I have to write a small routine to update this table, by sending in the LoginID and with help of IDirectory routines, get the Lastname, firstname and email. This is what i'm attempting to do, but getting confused with the right syntax. using (TSADRequestEntities context = UnityHelper.Resolve()) { var fpvalues = context.FOCALPOINTs.ToList(); foreach (var item in fpvalues) { IEnumerable<UserInfo> query = UnityHelper.Resolve<IUserDirectory>().Search(item.LoginID); //Here, FocalPoint is the table that has the loginID and the other fields //I need to update. the query shld now hv info on lastname etc..how do I //retrieve that value and update the table? } }

    Read the article

  • Problem with parsing SQL into table variable

    - by Stanley Ross
    I'm using the following code to read a SQL XML Variable into a table variable. I am getting the following error. " Incorrect syntax near '.'. " Can't quite Figure it out DECLARE @LOBS Table ( LineGUID varchar(40) ) DECLARE @lg xml SET @lg = '<?xml version="1.0" encoding="utf-16" standalone="yes"?> <Table> <LOB> <LineGuid>d6e3adad-8c53-4768-91a3-745c0dae0e08</LineGuid> </LOB> <LOB> <LineGuid>4406db8f-0d19-47da-953b-afc1db38b124</LineGuid> </LOB> </Table>' INSERT INTO @LOBS(LineGUID) SELECT ParamValues.ID.value('.','VARCHAR(40)') FROM @lg.nodes('/Table/LOB/LineGuid') AS ParamValues(ID)

    Read the article

  • Partioning the Table into .net - Creating columner database.

    - by Omky
    Hello Geeks, I am developing some tool for BI. There are terms like Fact, Dimensions and Measures. My application will connect to the normal database and read the data from that table. Now, I want to convert all this data into columnar database. That is all the columns from this table will be transfer into 3 tables each. Consider below table:- ID Product 1 XYZ 2 ABC 3 ABC Now, I want to convert the Product column i.e. dimension into 3 tables. dim_product_table:- ID Product 1 XYZ 2 ABC dim_product_fmk(fact map by key):- Where we will store key-value pair of Key Row 1 1 1 2 2 3 dim_product_fmr(fact map by row):- The above table will be reversed. Row Key 1 1 2 1 3 2 The another requirement is all above table should be generated dynamically and I should be able to JOIN all those. Can anybody help me? Thanks in advance.

    Read the article

  • Can't delete a mySQL table. (Error 1050)

    - by doublejosh
    I have a pesky table that will not delete and it's holding up my dev environment refresh :( I know this table exists. Example... mysql> select * from uc_order_products_qty_vw limit 10; +-----+-------------+---------+---------+---------+---------+ | nid | order_count | avg_qty | sum_qty | max_qty | min_qty | +-----+-------------+---------+---------+---------+---------+ | 105 | 1 | 1.0000 | 1 | 1 | 1 | | 110 | 5 | 1.0000 | 5 | 1 | 1 | | 111 | 1 | 1.0000 | 1 | 1 | 1 | | 113 | 5 | 1.0000 | 5 | 1 | 1 | | 114 | 1 | 1.0000 | 1 | 1 | 1 | | 115 | 1 | 1.0000 | 1 | 1 | 1 | | 117 | 2 | 1.0000 | 2 | 1 | 1 | | 119 | 3 | 1.3333 | 4 | 2 | 1 | | 190 | 5 | 1.0000 | 5 | 1 | 1 | | 199 | 2 | 1.0000 | 2 | 1 | 1 | +-----+-------------+---------+---------+---------+---------+ 10 rows in set (0.00 sec) However when I try to drop it... mysql> DROP TABLE IF EXISTS uc_order_products_qty_vw; Query OK, 0 rows affected, 1 warning (0.00 sec) It doesn't work, the table is still there, and the warning says this... mysql> show warnings limit 1; +-------+------+------------------------------------------+ | Level | Code | Message | +-------+------+------------------------------------------+ | Note | 1051 | Unknown table 'uc_order_products_qty_vw' | +-------+------+------------------------------------------+ 1 row in set (0.00 sec) Feeling pretty dumbfounded.

    Read the article

  • How to create a new line in the table cell

    - by Justin
    I am new to latex, and I am trying to create a table, but the content in the table cell is quite long, so I decided to create a new line for the cells. But I am not sure how to do that, could someone help me on that? Here is my code: \begin{table}[h!] \caption{Multirow table} \begin{center} \begin{tabular}{ |c|c|c| } \hline Observation(Species name) & Likelihood (Limnodynastes peronii Distribution Model) &Likelihood (Rhinella marina Distribution Model)\\ \hline Observation 1 (Limnodynastes peronii) &0.0712 &0.2699\\ \hline Observation 2 (Rhinella marina) &0.30 &0.013 \\ \hline \end{tabular} \end{center} \end{table}

    Read the article

  • Many-to-many relationship on same table with association object

    - by Nicholas Knight
    Related (for the no-association-object use case): http://stackoverflow.com/questions/1889251/sqlalchemy-many-to-many-relationship-on-a-single-table Building a many-to-many relationship is easy. Building a many-to-many relationship on the same table is almost as easy, as documented in the above question. Building a many-to-many relationship with an association object is also easy. What I can't seem to find is the right way to combine association objects and many-to-many relationships with the left and right sides being the same table. So, starting from the simple, naïve, and clearly wrong version that I've spent forever trying to massage into the right version: t_groups = Table('groups', metadata, Column('id', Integer, primary_key=True), ) t_group_groups = Table('group_groups', metadata, Column('parent_group_id', Integer, ForeignKey('groups.id'), primary_key=True, nullable=False), Column('child_group_id', Integer, ForeignKey('groups.id'), primary_key=True, nullable=False), Column('expires', DateTime), ) mapper(Group_To_Group, t_group_groups, properties={ 'parent_group':relationship(Group), 'child_group':relationship(Group), }) What's the right way to map this relationship?

    Read the article

  • Mapping enum to a table with hibernate annotation

    - by Thierry-Dimitri Roy
    I have a table DEAL and a table DEAL_TYPE. I would like to map this code: public class Deal { DealType type; } public enum DealType { BASE("Base"), EXTRA("Extra"); } The problem is that the data already exist in the database. And I'm having a hard time mapping the classes to the database. The database looks something like that: TABLE DEAL { Long id; Long typeId; } TABLE DEAL_TYPE { Long id; String text; } I know I could use a simple @OneToMany relationship from deal to deal type, but I would prefer to use an enum. Is this possible? I almost got it working by using a EnumType.ORDINAL type. But unfortunately, my IDs in my deal type table are not sequential, and do not start at 1. Any suggestions?

    Read the article

  • Problem with parsing XML into table variable

    - by Stanley Ross
    I'm using the following code to read a SQL XML Variable into a table variable. I am getting the following error. " Incorrect syntax near '.'. " Can't quite Figure it out DECLARE @LOBS Table ( LineGUID varchar(40) ) DECLARE @lg xml SET @lg = '<?xml version="1.0" encoding="utf-16" standalone="yes"?> <Table> <LOB> <LineGuid>d6e3adad-8c53-4768-91a3-745c0dae0e08</LineGuid> </LOB> <LOB> <LineGuid>4406db8f-0d19-47da-953b-afc1db38b124</LineGuid> </LOB> </Table>' INSERT INTO @LOBS(LineGUID) SELECT ParamValues.ID.value('.','VARCHAR(40)') FROM @lg.nodes('/Table/LOB/LineGuid') AS ParamValues(ID)

    Read the article

  • How Do I Update a Table From Another Table Only If the Result Count is 1?

    - by Russ Bradberry
    I have a table of 2 tables in a one to many relationship. I want to run an update script that will update the table with the FK of the related table only if there is one result (because if there is multiple then we need to decide which one to use, in another method) Here is what I have so far: UPDATE import_hourly_event_reports i SET i.banner_id = b.banner_id FROM banner b JOIN plan p ON b.plan_id = p.id WHERE b.campain_id = i.campaign_id AND b.size_id = i.size_id AND p.site_id = i.site_id HAVING COUNT(b.banner_id) = 1 As you can see, the HAVING clause doesn't quite work as I'd expect it. I only want to update the row in the import table with the id of the banner from the banner table if the count is equal to 1.

    Read the article

  • creating a table based on fields from three different tables

    - by ozlem
    Hi, I am using MS-Access 2003. I have three tables containing values of w,Q and L. In the Q table I have three fields: country_name, ISIC_code, and Q value. In the L table, there are three fields, country_name, ISIC_code, and L value. And in the w table there are two fields; country_name and w value. Country_names, and ISIC_code might be different for each table. What I want to do is create a new table with the values b(j)=w(i)L(ij)/Q(ij), where i is the country and j is the ISIC_code. So first I will check if the country name and ISIC_code are the same in L and Q tables. If they are equal I will calculate L/Q and then multiply this with w value of the same country if it exists. I appreciate any help.

    Read the article

  • multi-row update table with "different" data

    - by kralco626
    I think the best way to explain this is to tell you what I have. I have two tables A and B both have columns Field1 and Field2. However Field 2 is not populated in table B I want to populate field 2 of table B with field 2 of table A where field 1 of table A matches field 1 of table B. something like update tableB set Field2 = tableA.field2 where tablea.field1 = tableb.field1. The reason this may seem so odd and obscure is that I'm tyring to do an inital data load form an old database to a new one. please let me know if you need clarification

    Read the article

< Previous Page | 54 55 56 57 58 59 60 61 62 63 64 65  | Next Page >