Select column by comparing data from another column
I have a table of products by their price.
Product
Price
bag
1000
gloves
200
socks
400
hat
100
need to select all products where price is greater than price of "gloves"...
Dhananjay Rele
Select * from Table1
where Price > (Select Max(price) from Table1
where Product = 'gloves');
Russel Loski, MCT, MCSE Data Platform/Business Intelligence. Twitter: @sqlmovers; blog: www.sqlmovers.com
Similar Messages
-
Validate list column based on entry from another column
Hi there
I would like to ensure that a value is entered in list column B, if there is a value of 'Yes' in list column A.
I assume this formula is entered in the Validation settings of the list, but cannot work out what is required.
Is it something like? =IF([Col-A]="Yes",IF(LEN([Col-B]<1,TRUE,FALSE),TRUE)
Thanks
Asher
Fast, Cheap, Good. Choose any Two!Ahh, found a solution:
=IF([Col-A]="Yes",IF([Col-B]<>"",TRUE,FALSE),TRUE)
Now i need to do the same for other fields in the list, and these formulas must go together in the validation settings of the list, which is going to look messy.
If i want to do the same with columns C and D, how would i append this to the formula?
=IF([Col-C]="Yes",IF([Col-D]<>"",TRUE,FALSE),TRUE)
Thanks
Asher
Fast, Cheap, Good. Choose any Two! -
How can I Move data from one column to another in my access table?
I have two columns, one that stores current month’s data and one that stores last month’s data. Every month data from column 2 (this month’s data) needs to be moved to column 1 that holds last month’s data. I then null out column 2 so I can accumulates this month’s data.
I understand how to drop a column or add a column, how do I transfer data from one column to another.
Here is my trial code:
<cfquery name="qQueryChangeColumnName" datasource="#dsn#">
ALTER TABLE leaderboard
UPDATE leaderboard SET points2 = points3
</cfquery>
Unfortunately, I get the following error:
Error Executing Database Query.
[Macromedia][SequeLink JDBC Driver][ODBC Socket][Microsoft][ODBC Microsoft Access Driver] Syntax error in ALTER TABLE statement.
How can I transfer my data with the alter table method?I looked up the Access SQL reference (which is probably a
good place to start when having issues with Access SQL), and
it suggests you probably need a WHERE clause in there.
I agree the documentation is a good place to start. But you should not need a WHERE clause here.
Too few parameters. Expected 1.
If you run the SQL directly in Access, what are the results? At the very least, it should provide a more informative error message.. -
Need help - select data from NCLOB column problem
Hi,
Im having problem retrieving data from NCLOB columns via ODBC. After SQLExecdirect on my SELECT statement call to SQLFetch gives me following error:
ORA-24806 LOB form mismatch
I tried following two ways of data retrieval:
SQLExecDirect(hstmt,(SQLTCHAR*)szSQLStatement,SQL_NTS);
SQLBindCol(hstmt,3,SQL_C_TCHAR,chBuffer,sizeof(chBuffer),&iDataLen);
SQLFetch(hstmt);
OR
SQLExecDirect(hstmt,(SQLTCHAR*)szSQLStatement,SQL_NTS);
SQLFetch(hstmt);
SQLGetData(hstmt,3,SQL_C_TCHAR,chBuffer,sizeof(chBuffer),&iDataLen);
Both times call to SQLFetch gives me ORA-24806 LOB form mismatch error.
INSERT and UPDATE for this table works just fine.
If I change NCLOB type to CLOB works just fine, but I will be storing Unicode data, so using CLOB cant be a solution
Any ideas appreciated.
Thanks in advance,
Vlad
Server:
Oracle 9.2 database on Windows 2000 Server
NLS_LANGUAGE = AMERICAN
NLS_TERRITORY = AMERICA
NLS_CHARACTERSET = WE8MSWIN1252
NLS_NCHAR_CHARACTERSET = AL16UTF16
Client:
Unicode C++ application, connects via Oracle 9.2 ODBC driver on Windows XP
NLS_LANG = AMERICAN_AMERICA.WE8MSWIN1252
CREATE TABLE my_nclob_table (
id number (10,0) NOT NULL ,
name nvarchar2 (255) NOT NULL ,
description nvarchar2 (255) NULL ,
definition nclob NOT NULL ,
creation date NOT NULL ,
lastmodified date NOT NULL ,
CONSTRAINT PK_cat_pricelist PRIMARY KEY
id
#define nil NULL
#define null NULL
#define SQL_ERR(__sqlerr__) (((__sqlerr__) != SQL_SUCCESS) && ((__sqlerr__) != SQL_SUCCESS_WITH_INFO))
#define STOP_IF_SQL_ERR(__sqlerr__) \
do \
if (SQL_ERR(__sqlerr__)) goto stop_; \
} while (false)
void eqTestOracleLOBSelect(void)
SQLHENV henv = null;
SQLHDBC hdbc = null;
SQLHSTMT hstmt = null;
SQLRETURN retcode = SQL_SUCCESS;
TCHAR szSQLStatement[] = T("select id, name, definition from mynclob_table");
int iFetchedRows = 0;
TCHAR szMsg[512];
TCHAR chBuffer[2049];
SQLLEN iDataLen = 0;
try
retcode = eqOpenConnectionODBC(_T("myTestDsn"),_T("user"),_T("pwd"),henv,hdbc);
STOP_IF_SQL_ERR(retcode);
retcode = SQLAllocHandle(SQL_HANDLE_STMT, hdbc, &hstmt);
STOP_IF_SQL_ERR(retcode);
retcode = SQLExecDirect(hstmt,(SQLTCHAR*)szSQLStatement,SQL_NTS);
STOP_IF_SQL_ERR(retcode);
retcode = SQLBindCol(hstmt,3,SQL_C_TCHAR,chBuffer,sizeof(chBuffer),&iDataLen);
STOP_IF_SQL_ERR(retcode);
while (retcode == SQL_SUCCESS)
retcode = SQLFetch(hstmt);
if (retcode == SQL_NO_DATA)
retcode = SQL_SUCCESS;
break;
STOP_IF_SQL_ERR(retcode);
// retcode = SQLGetData(hstmt,3,SQL_C_TCHAR,chBuffer,sizeof(chBuffer),&iDataLen);
// STOP_IF_SQL_ERR(retcode);
++iFetchedRows;
stop_:
if (SQL_ERR(retcode))
MessageBox(null,_T("SQL statement execution error."),_T("Error"),MB_OK);
eqShowStatementError(SQL_HANDLE_STMT,hstmt,retcode);
} else {
_stprintf(szMsg,_T("SQL execution success. Fetched rows: %ld"),iFetchedRows);
MessageBox(null,szMsg,_T("Success"),MB_OK);
catch(...)
MessageBox(null,_T("Unknown exception in eqTestOracleLOBSelect"),_T("Unknown exception"),MB_OK);
if (hstmt != null)
SQLFreeHandle(SQL_HANDLE_STMT, hstmt);
hstmt = null;
if (hdbc != nil)
SQLFreeHandle(SQL_HANDLE_DBC, hdbc);
hdbc = nil;
if (henv != nil)
SQLFreeHandle(SQL_HANDLE_ENV, henv);
henv = nil;
SQLRETURN eqOpenConnectionODBC(TCHAR *szDSN,
TCHAR *szUser,
TCHAR *szPassword,
SQLHENV &henv,
SQLHDBC &hdbc)
SQLRETURN retcode;
henv = nil;
hdbc = nil;
//Allocate environment handle
retcode = SQLAllocHandle(SQL_HANDLE_ENV, SQL_NULL_HANDLE, &henv);
STOP_IF_SQL_ERR(retcode);
//Set the ODBC version environment attribute
retcode = SQLSetEnvAttr(henv, SQL_ATTR_ODBC_VERSION, (void*)SQL_OV_ODBC3, 0);
STOP_IF_SQL_ERR(retcode);
// Allocate connection handle
retcode = SQLAllocHandle(SQL_HANDLE_DBC, henv, &hdbc);
STOP_IF_SQL_ERR(retcode);
// Set login timeout to 5 seconds.
SQLSetConnectAttr(hdbc, SQL_LOGIN_TIMEOUT, (void*)5, 0);
STOP_IF_SQL_ERR(retcode);
retcode = SQLConnect(hdbc, (SQLTCHAR*)szDSN, SQL_NTS,
(SQLTCHAR*)szUser, SQL_NTS,
(SQLTCHAR*)szPassword, SQL_NTS);
stop_:
if (SQL_ERR(retcode))
MessageBox(null,_T("Connection Error."),_T("Error"),MB_OK);
if (hdbc != nil)
eqShowStatementError(SQL_HANDLE_DBC, hdbc,retcode);
SQLFreeHandle(SQL_HANDLE_DBC, hdbc);
hdbc = nil;
if (henv != nil)
eqShowStatementError(SQL_HANDLE_ENV, henv,retcode);
SQLFreeHandle(SQL_HANDLE_ENV, henv);
henv = nil;
} else MessageBox(null,_T("Connected."),_T("Success"),MB_OK);
return retcode;
void eqShowStatementError(SQLSMALLINT chHandleType, SQLHANDLE hHandle,long lErrOrig)
SQLRETURN nErr = SQL_SUCCESS;
int nRecNum = 1;
SQLTCHAR szSqlState[6];
SQLTCHAR szMsg[SQL_MAX_MESSAGE_LENGTH];
SQLSMALLINT nMsgLen;
SQLINTEGER nNativeError;
while ((nErr = SQLGetDiagRec(chHandleType,hHandle,nRecNum,
szSqlState, &nNativeError,
szMsg, sizeof(szMsg), &nMsgLen)) != SQL_NO_DATA)
szSqlState[5] = 0;
MessageBox(NULL,(const TCHAR *)szMsg,_T("ODBC Error"),MB_OK);
++nRecNum;Yes, the 9.2.0.2 driver can be downloaded from OTN. I don't believe it will solve your particular problem, but it will help in general. If you don't grab the latest version, you'll probably have to chack the "Force SQL_WCHAR Support" option in the DSN configuration.
From the help file
"The C data type, SQL_C_WCHAR, was added to the ODBC interface to allow applications to specify that an input parameter is encoded as Unicode or to request column data returned as Unicode. The macro SQL_C_TCHAR is useful for applications that need to be built as both Unicode and ANSI. The SQL_C_TCHAR macro compiles as SQL_C_WCHAR for Unicode applications and as SQL_C_CHAR for ANSI applications."
My first thought would be that your application is not being compiled as Unicode. If you substitute SQL_C_WCHAR for SQL_C_TCHAR when you're dealing with NCLOB columns, I suspect you'll have better luck.
More help file
"The SQL data types, SQL_WCHAR, SQL_WVARCHAR, and SQL_WLONGVARCHAR, were added to the ODBC interface to represent columns defined in a table as Unicode. These values are potentially returned from calls to SQLDescribeCol, SQLColAttribute, SQLColumns, and SQLProcedureColumns. In Oracle release 8.1.7.0.0 or 9.0.1.0.0, the Oracle database does not support encoding columns as Unicode. These values would not be returned from the ODBC Drivers for Oracle release 8.1.7.0.0 or for Oracle 9.0.1.0.0 databases.
In Oracle release 9.2.0.0.0, Unicode encoding was supported for SQL column types NCHAR, NVARCHAR2, and NCLOB. In addition, Unicode encoding was also supported for SQL column types CHAR and VARCHAR2 if the character semantics were specified in the column definition.
Starting with release 9.2.0.2.0, the ODBC Driver supports these SQL column types and maps NCHAR to the SQL data type SQL_WCHAR, NVARCHAR2 is mapped to SQL_WVARCHAR, and NCLOB is mapped to SQL_WLONGVARCHAR. The SQL CHAR column is mapped to SQL_WCHAR and the VARCHAR2 column is mapped to SQL_WVARCHAR if the character semantics are specified for the column. While the Force SQL_WCHAR Support option is still available in the 9.2.0.2.0 ODBC Driver, it is no longer required for Unicode support."
Justin -
SQL update one column from another column
I'm looking for a way to update a SQL column with a portion
of info from another column in the same table.
example of a sql command
UPDATE table1
SET table1.columnname1 = table1.columnname2
FROM table
WHERE blah blah blah
Here's the thing... I only need a portion of the data found
in the source column. I'm not sure how I would do this then.
for example, the database has countries and states combined
into one column like this 'US-DC', 'US-CA', US-FL', etc. I want to
separate these into two columns, a country column and a state
column.... and I dont want to go though all the results and do this
line by line. How would I write the SQL command so that it puts
just the country in the country column, and puts just the state in
the state column, and it omits the dash all together.
any ideas?It depends. Are you using PHP and mySQL or ASP and SQL?
If you are using mysql and PHP you could use the following
code to loop through all records in your datatbase.
$sql="SELECT * FROM tablename"; //SET tablename to the name
of your database table.
$result=mysql_query($sql)or die(mysql_error(). " - $sql");
for($x = 0; $row=mysql_fetch_assoc($result); $x++){
//set up the variables from the table
$ID=$row['ID']; //this is the primary key
$var1=$row['contrystatecolumn']; //this is the name of the
column which holds the country-state
$var2=explode("-", $var1); //now we explode the string to get
the country and the state seperated and place the results into an
array
$country=$var2[0]; //this is the first piece of the exploded
string in the array
$state=$var2[1]; //this is the second piece of the exploded
string in the array
//now we update the database record with the new information
//remember to replace the tablename with your actual table
name and the columns country and state with the acutal names of
your columns in your table
$sql2="UPDATE tablename SET country='$country'.
state='$state' WHERE ID='$ID'";
$result2=mysql_query($sql2)or die(mysql_error() . " -
$sql2");
This code will loop through every record in your table and do
what you want very quickly.
Hope this helps
Stan Forrest
Senior Web Developer
ATG Internet -
Return data from all columns apart from a certain data type.
Bit stuck on something, hope somebody here can help:
I want to do a 'select * from ' a table, to return all columns except ones of a certain datatype. ie. I want to return data from all columns, excluding columns of datatype 'SDO_GEOMETRY'.
This gives me the list of columns:
SELECT COLUMN_NAME
FROM USER_TAB_COLUMNS
WHERE TABLE_NAME = 'ORDER_ITEM'
AND DATA_TYPE <> 'SDO_GEOMETRY'; But I can't seem to take it any further...
Now if I knew the columns beforehand, then of course I could just list them, excluding the geometry column, but this is to be used for a plug-in for MS Word, where a user can pick database columns to dynamically fill a report from - but I don't want the geometry columns as these can't be handled in this way.Hi Reggie,
> connects to the database and presents a list of tables
My guess is that this macro is written so it selects from all_tab_cols.
Change that plugin and let it select from a view like the one above. That way, the users won't be able to see/pick anything that you are not able/willing to present for them.
Edit:
You could even tease your users, and let them see the columns, but not being able to pick them.
create or replace view available_tab_columns
as
select decode(pickable.data_type, null, 0, 1) pickable
,atc.* -- narrow down yourself
from all_tab_cols atc -- or maybe user_tab_cols
,(select 'CHAR' data_type from dual union all
select 'DATE' from dual union all
select 'NUMBER' from dual
-- complete positive list, yourself
) pickable
where atc.data_type = pickable.data_type(+);Regards
Peter
Message was edited by:
Peter Gjelstrup -
Displaying data from multiple columns into a single line graph
Post Author: hollowmatrix
CA Forum: WebIntelligence Reporting
Hey,I have an issue with the WEBI reporting.I have a data source that has multiple columns say ( month1, month2, month3, month4,.....month 12, month 13, ....month24) with the sales data for each month.Now say I call the month 1 to month 12 as "current year", and call month 13 - month 24 as "previous year".I want to put a prompt in the report which allows me to select between "current year" and "previous year".Based on the prompt value we get a graph of the sales vs month ....as in if we select "current year", then we get a graph of the sales Vs time( remember that the sales data for each month is in a different column.)and if we select "previous year" then we get a graph of the sales Vs time for previous year..( sales vs time for Month 13, month 14, month 15....month 24).I am not able to pull data from multiple columns into a single object that I can use to populate the graphs.Any help on the same will be appreciated .Hi,
<p>
please click
here (asktom) and look for the words "how about the other way round"
</p> -
Can I assign a task based on information from another column?
For example:
Let's say I have a column called "Question Type" and this column has multiple checkbox choice, those being:
Math
Science
History
English
Other
I want to allow users to be able to select multpile catagories for the question, like making one both math and science (which right now is completely possible)
I then want another column that says who the problem is assigned to. Bob is good at math, Joe at science, Jill at histroy, Jenn at English, and Billy handles everything else.
1) Is there a way that the task can be automatically assigned to my math expert Bob when I specify that the item I am adding is a math problem?
2) If I make a problem both math and science, can the task be assigned to both Bob and Joe?
Thanks in advance!Hi,
According to your post, my understanding is that you wanted to assign a task based on information from another column.
To assign task to multiple users, you need to:
Create a workflow and add action: Start Approval Process.
Click these user, select the Group, change One or a time(serial) to
All at onec(paralle).
Right click the action, select Properties, click ExpandGroups, change No to
Yes.
Then you can assign task to each member of the group.
I recommend to follow the steps as below to achieve what you want:
Create a custom list, add columns: Question Type(Choice); Assigned to(Person or Group).
Create a workflow associated the list.
Add conditions and action as below:
Then the task can be automatically assigned to 123 when the item is a math problem.
In addition, if you make a problem both math and science, the task can be assigned to both 456 and 789.
You can add other conditions to satisfy all the requirements.
Best Regards,
Linda Li
Linda Li
TechNet Community Support -
Help with lists and Numbers - how can I separate data from one column?
I have a series of data entries that have two or three pieces of information listed in one column (it was a list copied from the Internet). My data is in this form all in one column (ie Column A):
XXXX -- YYYY, ZZZZ
I want to be able to easily split that data into three columns (A, B, and C) without having to go through and manually separate all of the entries? I'd ideally like to have XXXX in one column, the '--' removed, YYYY in another column, and ZZZZ in a third column, like this:
Column A Column B Column C
====== ====== ======
XXXX YYYY ZZZZ
Is this possible? Any help is appreciated.BlooGoo
Open or paste your material in your favorite texteditor. TextEdit will suffice but there are better applications. Make sure your material is consistent, especially that there are no stray characters or extra spaces studded in the text. You can do this by using the clean up routine as described below.
1. Copy the set of characters you want to replace. In this case " -- " Note that there are spaces on each side of the dashes and you want to get rid of those.
2. Open the *Find and Replace* dialogue:
+Menu > Edit > Find > Find…+ (or command f)
Paste the " -- " into the Find: field, then type a comma in the Replace: field or
Copy and paste a tab from the document or
Click on the Advanced button and enter a tab using the Insert… button that appears.
3. Click *Replace All.*
Repeat as necessary. If it doesn't seem to work, copy and paste the bits that stick, usually there is something not visibly different but different as far as the computer iust concerned.
When you are finished save the results as a comma or tab delimited delimited .txt file and reopen it in Numbers.
Peter -
Hello, I am trying to compare data from one and the same table. In short I have:
NAME DTM CHARGE
Atanas 8/18/2012 9:33:23 AM 100
Atanas 8/18/2012 9:33:23 AM 101
Niki 8/18/2012 9:33:43 AM 200
Niki 8/17/2012 9:34:10 AM 100
Niki 8/18/2012 9:33:43 AM 201
Niki 8/17/2012 9:34:10 AM 101
Atanas 8/17/2012 9:34:29 AM 50
Atanas 8/17/2012 9:34:29 AM 51
Joro 8/18/2012 12:10:12 PM 400
Joro 8/17/2012 12:10:21 PM 300
Joro 8/18/2012 12:10:12 PM 401
Joro 8/17/2012 12:10:21 PM 301
And I want to sum CHARGE for each DTM for each NAME and present the difference in an additional column, the output should be like that:
NAME DTM CHARGE DTM CHARGE DIFFERENCE
Atanas 8/17/2012 9:33:23 AM 101 8/18/2012 9:33:23 AM 201 - 100
Niki 8/17/2012 9:33:23 AM 201 8/18/2012 9:33:23 AM 401 - 200
Joro 8/17/2012 9:33:23 AM 601 8/18/2012 9:33:23 AM 801 200
the DTM will be always /sysdate - 2/ and /sysdate - 1/,
Thanks in advance!It is not clear what you are trying to do, but it looks like:
with sample_table as (
select 'Atanas' name,to_date('8/18/2012 9:33:23 AM','mm/dd/yyyy hh:mi:ss am') dtm,100 charge from dual union all
select 'Atanas',to_date('8/18/2012 9:33:23 AM','mm/dd/yyyy hh:mi:ss am'),101 from dual union all
select 'Niki',to_date('8/18/2012 9:33:43 AM','mm/dd/yyyy hh:mi:ss am'),200 from dual union all
select 'Niki',to_date('8/17/2012 9:34:10 AM','mm/dd/yyyy hh:mi:ss am'),100 from dual union all
select 'Niki',to_date('8/18/2012 9:33:43 AM','mm/dd/yyyy hh:mi:ss am'),201 from dual union all
select 'Niki',to_date('8/17/2012 9:34:10 AM','mm/dd/yyyy hh:mi:ss am'),101 from dual union all
select 'Atanas',to_date('8/17/2012 9:34:29 AM','mm/dd/yyyy hh:mi:ss am'),50 from dual union all
select 'Atanas',to_date('8/17/2012 9:34:29 AM','mm/dd/yyyy hh:mi:ss am'),51 from dual union all
select 'Joro',to_date('8/18/2012 12:10:12 PM','mm/dd/yyyy hh:mi:ss am'),400 from dual union all
select 'Joro',to_date('8/17/2012 12:10:21 PM','mm/dd/yyyy hh:mi:ss am'),300 from dual union all
select 'Joro',to_date('8/18/2012 12:10:12 PM','mm/dd/yyyy hh:mi:ss am'),401 from dual union all
select 'Joro',to_date('8/17/2012 12:10:21 PM','mm/dd/yyyy hh:mi:ss am'),301 from dual
select nvl(s1.name,s2.name) name,
s1.dtm,
s1.charge,
s2.dtm,
s2.charge,
s2.charge - s1.charge diff
from (
select name,
dtm,
sum(charge) charge
from sample_table
where dtm >= trunc(sysdate) - 1
and dtm < trunc(sysdate)
group by name,
dtm
) s1
full join
select name,
dtm,
sum(charge) charge
from sample_table
where dtm >= trunc(sysdate)
and dtm < trunc(sysdate) + 1
group by name,
dtm
) s2
on s1.name = s2.name
NAME DTM CHARGE DTM CHARGE DIFF
Atanas 17-AUG-12 101 18-AUG-12 201 100
Niki 17-AUG-12 201 18-AUG-12 401 200
Joro 17-AUG-12 601 18-AUG-12 801 200
SQL> SY. -
Hello,
I would like to populate a list column with data (Lot #'s) from a list on another sp farm updating frequently. I want to use the column as a lookup to the Lot #'s. Possible? Authentication?
Thank you,
Andrea
AndreaHi,
According to your description, you want to populate a list column with the data
from a list in another SharePoint Farm.
Is your another SharePoint Farm in the same domain you are trying to access?
If yes, you can use Client Object Model and set the creadentials to access the
data like below:
context.Credentials = new NetworkCredential("user", "password", "domain");
Here is a similiar thread for your reference:
http://social.msdn.microsoft.com/Forums/office/en-US/66f1ed1d-4df2-4da2-bfda-e3d1747a76cf/get-different-sharepoint-server-list-data-using-custom-webpart?forum=sharepointdevelopmentprevious
More information about get list data using Client Object Model:
http://msdn.microsoft.com/en-us/library/office/fp179912(v=office.15).aspx
Best regards,
ZhengyuGuo
Zhengyu Guo
TechNet Community Support -
How to display data from a recordset based on data from another recordset
How to display data from a recordset based on data from
another recordset.
What I would like to do is as follows:
I have a fantasy hockey league website. For each team I have
a team page (clubhouse) which is generated using PHP/MySQL. The one
area I would like to clean up is the displaying of the divisional
standings on the right side. As of right now, I use a URL variable
(division = id2) to grab the needed data, which works ok. What I
want to do is clean up the url abit.
So far the url is
clubhouse.php?team=Wings&id=DET&id2=Pacific, in the end all
I want is clubhouse.php?team=Wings.
I have a separate table, that has the teams entire
information (full team name, short team, abbreviation, conference,
division, etc. so I was thinking if I could somehow do this:
Recordset Team Info is filtered using URL variable team
(short team). Based on what team equals, it would then insert this
variable into the Divisional Standings recordset.
So example: If I type in clubhouse.php?team=Wings, the Team
Info recordset would bring up the Pacific division. Then 'Pacific'
would be inserted into the Divisional Standings recordset to
display the Pacific Division Standings.
Basically I want this
SELECT *
FROM standings
WHERE division = <teaminfo.division>
ORDER BY pts DESC
Could someone help me, thank you.Assuming two tables- teamtable and standings:
teamtable - which has entire info about the team and has a
field called
"div" which has the division name say "pacific" and you want
to use this
name to get corresponding details from the other table.
standings - which has a field called "division" which you
want to use to
give the standings
SELECT * FROM standings AS st, teamtable AS t
WHERE st.division = t.div
ORDER BY pts DESC
Instead of * you could be specific on what fields you want to
select ..
something like
SELECT st.id AS id, st.position AS position, st.teamname AS
team
You cannot lose until you give up !!!
"Leburn98" <[email protected]> wrote in
message
news:[email protected]...
> How to display data from a recordset based on data from
another recordset.
>
> What I would like to do is as follows:
>
> I have a fantasy hockey league website. For each team I
have a team page
> (clubhouse) which is generated using PHP/MySQL. The one
area I would like
> to
> clean up is the displaying of the divisional standings
on the right side.
> As of
> right now, I use a URL variable (division = id2) to grab
the needed data,
> which
> works ok. What I want to do is clean up the url abit.
>
> So far the url is
clubhouse.php?team=Wings&id=DET&id2=Pacific, in the end
> all
> I want is clubhouse.php?team=Wings.
>
> I have a separate table, that has the teams entire
information (full team
> name, short team, abbreviation, conference, division,
etc. so I was
> thinking if
> I could somehow do this:
>
> Recordset Team Info is filtered using URL variable team
(short team).
> Based on
> what team equals, it would then insert this variable
into the Divisional
> Standings recordset.
>
> So example: If I type in clubhouse.php?team=Wings, the
Team Info recordset
> would bring up the Pacific division. Then 'Pacific'
would be inserted into
> the
> Divisional Standings recordset to display the Pacific
Division Standings.
>
> Basically I want this
>
> SELECT *
> FROM standings
> WHERE division = <teaminfo.division>
> ORDER BY pts DESC
>
> Could someone help me, thank you.
> -
To get data from another user?
Hi,
I am in "scott" user. I need to use the data from another user for example user "sys". i know the database name(i.e.user@database), but i dont know the password of that user.
I think by using dblink it is possible. If it is correct then Is there any other way for this? If dblink is not correct way then please reply the correct way.
Thanks & Regards,
ShyamYou only need to use a database link if the data is in another database instances.
If you want to query data in another users schema on the same database you just need to have rights to do so. You either need to have
select any table system privilage granted to the user (not recommended for security reasons)
be granted select privalage on the object from the user
be granted a role that has select privelges on the object you want to query.
If you log in as system to the database you can grant select on the object to scott
sql> grant select on <schema>.<table> to scott;
now logged in as scott you can select from the table
sql> select * from <schema>.<table>
where <schema> is the other user and <table> is the name of the table that you want to select from. -
Chrome missing in Import data from another browser
I use both chrome and firefox portable from site portableapps because mozilla doesn´t have a portable version.
My dilemma today is this:
I always had on firefox on menu "import and backup" > > "import data from another browser" listing chrome like this
https://support.mozilla.org/media/uploads/gallery/images/2012-02-24-10-35-53-97ff60.png
today i want to import chrome bookmarks to firefox but chrome is missing on the list, in the past i always had it there listed now is just pointing to IE
Do i need chrome installed on machine to grab something from registry?
By what i can remember always had that option on portable versions, i am importating this with a fresh pc machine because i installed now windows where i previously wiped the disk from manufacturer erasing tool.
i digged the net and on questions here but cant find why its missing, can you guys tell me why?
P.S- i would like to say that this site, Mozilla and Mozilla support, forums and community are the best service i´ve seen in years over the whole web i believe its really the best one and am not writing this because of this question, only thing missing is having Mozilla apps portable, a online chat would be cool too for the community
Oh god i hope today the "fox" saves me cause i can´t find solution on this
You guys take it easy.....Do you mean the portable version of Google Chrome as well?
*http://portableapps.com/apps/internet/google_chrome_portable
Which that version you probably need to export the bookmarks to an HTML file and import that file in Firefox.
You can open the Bookmarks Manager in Google Chrome (wrench icon > Bookmarks > Bookmarks Manager) and select "Tools > Export Bookmarks"<br />
This will export the Chrome bookmarks to a file bookmarks.html.<br />
You can import that file in Firefox: Bookmarks > Show All Bookmarks > Import & Backup > Import HTML : "From File"
* http://www.google.com/support/chrome/bin/answer.py?hl=en&answer=96816 - Bookmarks : Import or export bookmarks - Google Chrome Help -
Question - Comparing data from 2 databases
I'm new to Oracle - I'm trying to compare data from 2 separate databases.
I'm trying to get data from both databases based on a common TRACKING_NUMBER. The issue is that in one database there are additional 0s in front of the Tracking_Number.
So I'm trying to find out what I can put in my query to remove those zero's in front of the tracking number. I have the query below - it's very long.
SELECT DISTINCT cm.TRACKING_NUMBER_TYPE AS HType,
TRUNC(cm.CREATED_DATE) as CodeMoveDate,
SUBSTR(cm.CODE_MOVE_DESC, 1, 50) AS Description,
cm.TRACKING_NUMBER AS TrackingNumber,
rq.Plant_Name as Location,
jr_eur.Assignee as Tracker,
TRUNC(MAX(jr_spec.Journal_Date)) as Date_Spec,
TRUNC(MAX(jr_app.Journal_Date)) as Date_Approved,
TRUNC(MAX(jr_ut.Journal_Date)) as Date_Unit,
TRUNC(MAX(jr_qa.Journal_Date)) as Date_Assurance,
TRUNC(MAX(jr_eur.Journal_Date)) as Date_Enduser,
TRUNC(MAX(jr_gv.Journal_Date)) as Date_Gatekeeper,
TRUNC(MAX(jr_prod.Journal_Date)) as Date_Move,
TRUNC(MAX(jr_eun.Journal_Date)) as Date_Notification,
TRUNC(MAX(jr_pver.Journal_Date)) as Date_Production,
TRUNC(MAX(jr_udoc.Journal_Date)) as Date_Documentation
FROM PROJMAN.PM_CODE_MOVES_V cm,
PROJMAN.PM_Requests_V rq,
PROJMAN.PM_Journals_V jr_spec,
PROJMAN.PM_Journals_V jr_app,
PROJMAN.PM_Journals_V jr_ut,
PROJMAN.PM_Journals_V jr_qa,
PROJMAN.PM_Journals_V jr_eur,
PROJMAN.PM_Journals_V jr_gv,
PROJMAN.PM_Journals_V jr_prod,
PROJMAN.PM_Journals_V jr_eun,
PROJMAN.PM_Journals_V jr_pver,
PROJMAN.PM_Journals_V jr_udoc
WHERE cm.TRACKING_NUMBER = LTRIM(rq.Request_ID(+))
AND cm.TRACKING_NUMBER = jr_spec.Request_ID(+)
AND cm.TRACKING_NUMBER = jr_app.Request_ID(+)
AND cm.TRACKING_NUMBER = jr_ut.Request_ID(+)
AND cm.TRACKING_NUMBER = jr_qa.Request_ID(+)
AND cm.TRACKING_NUMBER = jr_eur.Request_ID(+)
AND cm.TRACKING_NUMBER = jr_gv.Request_ID(+)
AND cm.TRACKING_NUMBER = jr_prod.Request_ID(+)
AND cm.TRACKING_NUMBER = jr_eun.Request_ID(+)
AND cm.TRACKING_NUMBER = jr_pver.Request_ID(+)
AND cm.TRACKING_NUMBER = jr_udoc.Request_ID(+)
AND jr_spec.Journal_Status(+) = 'Spec Doc'
AND jr_app.Journal_Status(+) = 'Approved'
AND jr_ut.Journal_Status(+) = 'Unit Test'
AND jr_qa.Journal_Status(+) = 'Quality Assurance'
AND jr_eur.Journal_Status(+) = 'End User Review'
AND jr_gv.Journal_Status(+) = 'Gatekeeper Verificat'
AND jr_prod.Journal_Status(+) = 'Move to Production'
AND jr_eun.Journal_Status(+) = 'End User Notificatio'
AND jr_pver.Journal_Status(+) = 'Production Verificat'
AND jr_udoc.Journal_Status(+) = 'User Documentation'
AND cm.TRACKING_NUMBER_TYPE = 'H'
and cm.CREATED_DATE >{d '2006-12-31'}
GROUP BY
cm.TRACKING_NUMBER_TYPE,
TRUNC(cm.CREATED_DATE),
cm.CODE_MOVE_DESC,
cm.TRACKING_NUMBER,
rq.Plant_Name,
jr_eur.Assignee
ORDER BY TRUNC(cm.CREATED_DATE)I recommend using a product.
I used to write scripts and procedures, but no more!
Reason is: you save time. A lot of time. You pay few hunderes $ once for the product.
If you do it yourself, you waste half-days doing it properly.
A good tool for database compare is Comparenicus (www.compareniucs.com).
I'm using it for 6 months now and it saves me a lot of time.
Maybe you are looking for
-
Need some help in creating client proxy to call webservice
Hi experts, I am new to ABAP so couldnt understand the SAP ABAP jargons. On of my colleague has written one search help exit function and i need to use that and have to write client proxy to establish connection to webservice. I never worked on proxy
-
I am suddenly having a problem when I export to a folder on my computer from LR3. I do this all the time and I don't know what has gone wrong. Today I exported a group of files to a folder on my computer which was going to be used to burn a cd and
-
How to pass rowset properties out of mapping
I want to pass out the count of records inserted, and the value of a field out of a mapping to send an email with this information. I cannot see how to accomplish this. I tried setting up an aggregate, and passing result to an Output parameter, but I
-
Mismatch memories on iMac5.2 1.83GHz Intel Core 2 Duo?
Can I use mismatched memories on my iMac5.2 (late 2006) 1.83 GHz Intel Core 2 Duo (with Intel GMA 950 Graphics sharing 64 MB of system memory)? I need to upgrade my computer memory to at least 1 GB from my existing 512 MB (2 x 256MB). I'd love to go
-
I've read a lot about Bridge not uninstalling along with PS CS3 even though it is part of CS3 and not a stand alone program. I just upgraded to CS4 and can't afford the space keeping cs3 around, and like everyone lese, after uninstalling CS3, Bridge