I don't really know how to explain this one. I've taken a table, created a copy of it with a specific column as varchar instead of char. Then I've copied the data from one table into the new one. However, when I then programmatically add a new value to the table, the column that was previously char(200) is still being padded with space u...
Hi
ist there a way to merge two tables in MySQL virtually so I could query and insert data?
(which is basicly splitted)
exp.
table
id
active
foo
table_meta
table_id
language
text
what I like to do is using something like this instead of sql-join
INSERT INTO table_join SET active = 1, language = 'en';
regards
jim
...
Hiya,
I'm building a reporting app, and so I'm crunching an awful lot of data. Part of my approach to creating the app in an agile way is to use SQL views to take the strain off the DB if multiple users are all bashing away.
One example is:
mysql_query("CREATE VIEW view_silverpop_clicks_baby_$email AS SELECT view_email_baby_posit...
Hello i would like to ask how to create a php code for mysql to do the fallowing thing
if active = 1 to do current amount + 2000
id, eid, amount, apply 1, apply 2, apply 3, active
1 1788 500 NULL NULL NULL 1
2 1956 1000 NULL NULL NULL 1
3 2035 ...
I have a two tables as follows:
product category(t1):
id
name
product master(t2):
id
name
category
Now I have the following query to fetch the products and the associated category name in one query only:
select
*,
(select name from t1 where t1.id=t2.category) as 'category'
from
t2
which is working perfectly. Now what ...
Why can't we use count(distinct *) in SQL? As in to count all distinct rows?
...
My warehouse datamart data is split across 3 databases on the same server. This is Proof-Of-Concept project with three extracts that were loaded into individual databases.
While pulling into a cube, I am essentially doing this:
SELECT * FROM DB1.dbo.Fact_Pres
UNION
SELECT * FROM DB2.dbo.Fact_Pres
UNION
SELECT * FROM DB3.dbo.Fact_Pres
...
I have a table used by one piece of 3rd party software (say user_fields) that has for each row a user_id, a field_id and a field_value. Crappy I know.
I also have another user table of my own, users, that contains the values needed to populate this, except the field_id which is "magic" and corresponds to the custom field mapping.
How c...
Im trying to write an SQL query that will check in the table ‘persons’ in the column ‘rName’ for say a name “jack” and if it exists then UPDATE that row else INSERT a new row with the new rName.
I’v been trying out IF/ELSE statements but haven’t really seen how they work.
Or is there a better way to do what I want without If/ELSE? (I ha...
Hello,
I have two table:
EMP
emp_id | Name | Surname |
1 | Bob | Park |
2 | Annie| South |
3 | Eric | P. |
PROJECT
proj_id | Tester_1 | Tester_2 | Tester_3 |
1 | 2 | 3 | 1 |
Now I am trying to make a view, so that I have the following
proj_id | Tester_1_Name | Tester_2_Na...
My limited SQL knowledge prompted this post!
I have a stored procedure that runs a series of updates.
There are 6 update statements, that could very well be mashed into one large update statement, but I dont know what that will mean for performance.
Table basics:
6 tables are hit. 3 of which will never have more than about 5000 rec...
Hi all,
it seems like a typical question but it's different.
I have a table with an id and 3 timestamp fields (to simply). Initially all 3 fields are null, and they get filled with values. Examples of rows are:
id time1 time2 time3
1 1259625661 1259643563 null
2 null 1259621231 null
3 1259625889 null 1259644511...
Hello all,
Well, as i mentioned, i am using an app_code file to handle my connections to the DB, using two public static functions. one for the SqlDataReader when using SQL and the other is XmlReader when using XML.
The thing is, in ExecuteReader i can write:
return cmd.ExecuteReader (CommandBehavior.CloseConnection);
and that will cl...
I have a view that is returning four columns of data to be pushed to an external program. When I simply query the view ("Select * from schema.view_name") I get 10353 rows. When I run the actual SQL that created the view (I literally copied and pasted what Oracle had stored, minus the "Create or Replace" statement), I get 238745 rows.
An...
I have a table with a primary key that is a varchar(255). Some cases have arisen where 255 characters isn't enough. I tried changing the field to a text, but I get the following error:
BLOB/TEXT column 'message_id' used in key specification without a key length
how can I fix this?
edit: I should also point out this table has multiple...
I have created a custom data type enum like so:
create type "bnfunctionstype" as enum ( 'normal', 'library', 'import', 'thunk', 'adjustor_thunk' );
From an external data source I get integers in the range [0,4]. I'd like to convert these integers to their corresponding enum values. How can I do this? I'm using PostgreSQL 8.4.
...
Basic SQL statement question -
I have a table (myUsers) that contains the column "UserID." The same UserID can appear one to many times in these rows. I'm looking for a query that will give me back the specific userIDs that appear the most in this table, and also with their count. Any thoughts?
Thanks in advance!
...
I'm attempting to create percentile scores. My query generates the ranks correctly, but the divide does nothing(the ranks are displayed in the columns rather than scores)
"/"(RANK() OVER(ORDER BY "Disk IO"),Count(*)) "Disk IO Score"
I've also tried generating the rank then selecting that and dividing, but it has the same result.
SELE...
Hi,
I have a table "AuctionResults" like below
Auction Action Shares ProfitperShare
-------------------------------------------
Round1 BUY 6 200
Round2 BUY 5 100
Round2 SELL -2 50
Round3 SELL -5 80
Now I need to aggregate results by every auction with BUYS after ne...
Having two tables, "users" and "lists", and a many-to-many "subscriptions" table relating users to lists (thus having foreign keys user_id and list_id), what would be a single SQL query to find all the users that don't have any subscription with a specific list_id (naturally including the users that have no subscriptions at all)?
...