MySQL - Alias Question
Hi Chaps,
Have a quick one for you...
In a SQL Query, I know you can create an alias for column name, eg.
...tbl_jobxml.job1 as job2
but can you create an alias for the value within that column, eg.
...tbl_jobxml.job1='y' as job2='Complete'
Sorry if this is dumb question, but better to ask that claim ignorance!
Hi Guys,
sorry to the delay in responding, basically this is what I want to do:
I want to show all results when:
- tableA
projectstatus='complete'
- tableB
projectstatus='complete'
- tableC
jobstatus='y'
I'm familiar with UNIONs and INNER JOINs, it's just not sure how to go about getting all the results form the 3 tables, when the values are different.
Similar Messages
-
I began playing with JDBC a few days ago. I set up a database using mySQL and wrote a simple java program that will connect to it. Works good from the computer that holds the database.
I try and run the same program from my secondary computer which does not have mySQL or ODBC mySQL drivers, I get com.mysql.jdbc.Driver for an error message. (Trying to access the database on my main computer via ip/databasename)
My Question is, do you HAVE to have mySQL or Connector/ODBC installed on a computer if you wish to connect to a database on other computer??
Here's where it prints the error message...
try
Class.forName("com.mysql.jdbc.Driver");
catch (Exception e)
JOptionPane.showMessageDialog(null, "ERROR = " + e.getMessage());
I use this as my url..
private final String url = "jdbc:mysql://122.122.122.122:3306/test123";
Say I want to make a simple web applet that will
access a database on my computer. The only way my
vistors to my website will be able to access the
database via the web applet is by having mySQL JDBC
driver installed on their computers?yes.
however.
you can package up the JDBC driver as part of your jar with your applet so it doesn't require the user to "install" anything. it's just part of your applet. -
Hi all,
I know this is not strcitly a JDBC problem, but i was wodering if you have any ideas anyhow...
I've implemented an Index on two of my columns in a table in my MySQL db. My question is, when i insert new rows into the database, is the index automatically updated? If not, how do I go about updating the Index?
Many thanks,
BBBI thought the database would manage that for you. AFAIK, you don't have to do anything. That's the way it is in Oracle. I thought that was true for all RDBMS. - MOD
-
Coldfusion fetch mysql query question
Hi:
Here is my coldfusion code:
<cfquery name = "query" datasource = "cfmysql" result = "result">
SELECT COUNT(*) FROM students WHERE gender = 'boy'
</cfquery>
And then I want to check if value is greater than 0. I then do:
<cfif existSearchHintsQuery.COUNT(*) gt 0>
But coldfusion gives me an error at the * character, the colume of the mysql result is "COUNT(*)", so I really need the * character.
How do I fetch that count number?
Thanks.You need to use an alias so you can access the COUNT(*) like any other column:
<cfquery name="yourQueryName" datasource="cfmysql" result="result">
SELECT COUNT(*) AS TotalStudents FROM students WHERE gender = 'boy'
</cfquery>
<cfif yourQueryName.totalStudents GT 0>
... do something ...
</cfif>
Also, read up on using cfqueryparam (if you are not using it already)
http://livedocs.adobe.com/coldfusion/8/Tags_p-q_18.html -
Let's say that I am making a java program that connects to a Mysql database and uses the database "MyDatabase".
Forgive me, but I am relating this to a Microsoft Access database.
The database is not on a network, but is (or will be installed) on the user's machine. In otherwords, the database will be on the user's machine and the changes to the database will only affect that user.
If I am to let a user use this program, will they have to also have Mysql installed for the program to access the database and pull information from it?
--Thanks!Let's say that I am making a java program that
connects to a Mysql database and uses the database
"MyDatabase".[snip]
The database is not on a network, but is (or will be
installed) on the user's machine.[snip]
If I am to let a user use this program, will theyhave
to also have Mysql installed for the program toaccess
the database and pull information from it?Yes.
(if you are asking if the code could directly
access/manipulate MySQL datafiles without going
through the MySQL program, I suppose in theory you
could, but I seriously doubt you really want to)The reason being is that it would be a client database for their own use, as oppose to sharing the database with others.
In any case, Thanks!
Next question: is there any place where I could go to find code that would treat the Mysql database as a client database (so far, the code that I found requires Mysql to be installed and running in the background on the user's machine)? -
well I just got Mysql Browser query and I was modifying some of the variables inside the table from varchar to longtext and it ask me for the charset. So my question is: Which one should I use ? The application its used on a spanish enviroment.
Thanks!Uhh, one of the sets that contains spanish characters, I suppose...
http://dev.mysql.com/doc/mysql/en/charset-charsets.html
looks like your choices are some universal charsets (utf8 and ucs2) and some "western" sets. You probably ought to pick a charset that also has a spanish collation (if you want to do native-language sorting). -
Apex 3.1.2 with Oracle 11G - /i/ alias question
I just recently installed Oracle 11G with Apex 3.0 and then upgraded Apex to 3.1.2. I am able to login and do most of the regular tasks. I built an application using custom flash components. When I used Apex with Oracle 10G, I can copy the SWF files to the directory mapped to /i/ alias and it worked fine.
Same is not working with 11G. First of all I am not sure to what path the /i/ in 11G is mapped to. Any help is greatly appreciated. I used Embedded Pl/Sql gateway.
Thanks
Karthik
Edited by: karthikm on Dec 30, 2008 4:40 PM
Edited by: karthikm on Dec 30, 2008 4:40 PMDingfei,
You need to make sure that you have access to the "i" folder. Make sure that the alias defined in your dads.conf is properly configured.
Regards,
Dan
http://danielmcghan.us
http://sourceforge.net/projects/tapigen -
Hi All,
I've got 2 MySQL tables, movie and movie_tag. The movie table contains a movie_id column and the movie_tag table contains 2 columns, movie_id and tag_id. I know how to correctly join them, what I would like to know is if I have this query:
SELECT * FROM movie LEFT JOIN movie_tag USING movie_id
and save it as a result set in a language like PHP or Python can I:
1. Loop through and only display each movie_id once, BUT...
2. Also display all the tag_id's without nested-looping.
I.e. I would like to list then something like:
-- movie_id_1
|-- tag_id_1
|-- tag_id_2
-- movie_id_2
|-- tag_id_1
Thanks for any help you can give!Your query will give you the cartesian product of movie and movie_tag, which means (given your example list) the output rows will look like this:
movie_id_1 | tag_id_1
movie_id_1 | tag_id_2
movie_id_2 | tag_id_1
You can then create the list you've shown above by post-processing in your procedural language of choice: loop over the results, track when movie_id changes, indent accordingly. -
Zsh alias question [solved (sort of)]
In my .zshrc, I have this line:
source /path/to/aliases_file
. The aliases file contains the line
alias -- -=popd
. When I log in or create a new urxvt window, I get the message:
/path/to/aliases_file:1: bad option: -=
But if I run exactly the same command manually,
alias -- -=popd
it works. Can anyone explain this to me? And is there a way to get the source command to apply that alias file without throwing the error?
Thanks.
Last edited by ibrunton (2012-09-15 13:49:29)eyeck% zsh --version
zsh 5.0.0 (x86_64-unknown-linux-gnu)
eyeck% cat .zshrc
source aliases
eyeck% cat aliases
alias -- -=popd
eyeck% zsh
eyeck% -
popd: directory stack empty
eyeck% alias
-=popd
run-help=man
which-command=whence
Copied and pasted the command directly from your post. I am using extra/zsh 5.0.0-2 without any custom patches or anything of the sort.
Last edited by eyeck (2012-09-15 02:55:03) -
Up till now I have been on a server using version 4.1 but I
have now
purchased my own little bit of the internet and I have the
option of
installing version 5, are there any major advantages to me in
doing this in
relation to the shopping cart software I am using i.e. WA
eCart and
Cartweaver ? or are the new features not relevant to these
types of
applications until I start rolling my own so to speak.
Thanks
Dave Buchholz
I-CRE8
www.i-cre8.co.uk
Skype ID: I-CRE8Thanks David
as ever concise and constructive advice
Dave Buchholz
I-CRE8
www.i-cre8.co.uk
Skype ID: I-CRE8
"David Powers" <[email protected]> wrote in message
news:eeu26s$ft$[email protected]..
Dave Buchholz wrote:
> Up till now I have been on a server using version 4.1
but I have now
> purchased my own little bit of the internet and I have
the option of
> installing version 5, are there any major advantages to
me in doing this
> in
> relation to the shopping cart software I am using i.e.
WA eCart and
> Cartweaver ? or are the new features not relevant to
these types of
> applications until I start rolling my own so to speak.
If you have the option of version 5, take it. It will make
upgrading to
subsequent versions a lot easier. MySQL 5 offers improved
features such
as stored procedures and views. Although they're not
supported by
Dreamweaver, you may find them useful, particularly once you
decide to
start developing things on your own.
AFAIK, MySQL 5.2 is likely to be the important upgrade
(probably at
least a year away), as it's planned to introduce support for
foreign key
restraints in the default MyISAM table. At the moment, only
InnoDB
tables have support for foreign key restraints, but most
hosting
companies don't provide support for InnoDB.
David Powers
Adobe Community Expert
Author, "Foundation PHP for Dreamweaver 8" (friends of ED)
http://foundationphp.com/ -
I have two DATETIME columns in a table. Is it possible to get the difference between the two dates and then format the output as H:M P?
I've been trying to get this to work for a while... but now I'm not even sure it's possible.I have two DATETIME columns in a table. Is it possible
to get the difference between the two dates and then
format the output as H:M P?A MySql-query along these lines might just do the job:
SELECT SEC_TO_TIME(UNIX_TIMESTAMP(yourDATETIME_1) - UNIX_TIMESTAMP(yourDATETIME2)) AS TimeDifference FROM yourTable;
It gives you the time difference (conveniently availaible as TimeDifference) in a HH:MM:SS format. Additionally, you can use the TIME_FORMAT() function to convert it to a more suitable format, e.g.
SELECT TIME_FORMAT(SEC_TO_TIME(UNIX_TIMESTAMP(yourDATETIME_1) - UNIX_TIMESTAMP(yourDATETIME2)), "%H:%i") AS TimeDifference FROM yourTable;
- giving you the hours and minutes. For details, see http://www.mysql.com/doc/en/Date_and_time_functions.html
Maybe all of this isn't exactly what you were looking for, but at least it should give you an idea of the possibilities and something to work from. Hopefully!
nr -
Not sure if this is the appropriate forum for a mySQL upgrade--but since Oracle owns mySQL now I thought I would give it a try.
I just ran the mysql_upgrade and can't locate the log to review. Anyone know where the log is dumped?Hi
Please post your issuen on forums.mysql.com/
Regard
Helios -
Hello,
I am writing a java program to connect with mysql, the database two tables: order and items.
In the order the orderNo is a unique value, and appears again the items table for each book ordered.
Could any advise, if I wanted to delete the orderNo from the order table, and also delete all the records in the items table with the same orderNo, could I achieve this in one sql statement?
Thanks
table (order):
orderNo
table (items):
orderNo
bookname
quantity
priceexample for orderNo 2:
DELETE items,order FROM items,order WHERE order.orderNo=2 and items.orderNo=2Haven't tried this myself, though.
regards -
OK fellas. Gentle on the newbie.
I have my datasource set up, I have the MySQL Query Browser
working and I'm poking around a bit with the World dB tables.
I can't seem to get why this:
SELECT * FROM countrylanguage c; ORDER BY IsOfficial;
isn't doing a thing. No error, but it surely doesn't seem to
be alphabetizing on IsOfficial.
Thanks!
RickTry adding ASC or DESC to the end of it.
Brendon
"webspinner" <[email protected]> wrote in
message
news:eo6akr$2r7$[email protected]..
> OK fellas. Gentle on the newbie.
>
> I have my datasource set up, I have the MySQL Query
Browser working and
> I'm
> poking around a bit with the World dB tables.
>
> I can't seem to get why this:
> SELECT * FROM countrylanguage c; ORDER BY IsOfficial;
>
> isn't doing a thing. No error, but it surely doesn't
seem to be
> alphabetizing
> on IsOfficial.
>
> Thanks!
>
> Rick
> -
OT: MySQL GROUP_CONCAT Question
Are there any MySQL gurus here who understand MySQL's
GROUP_CONCAT
function? I'm trying to figure out how it works.
This is the query I started with:
$res = mysql_query ("SELECT * FROM cia_ppl CP
LEFT JOIN gw_geog GG on GG.IDArea = CP.ID_Name
LEFT JOIN cia_notes CN on CN.IDName = CP.ID_Name
WHERE CP.Pop != 0") or die (mysql_error());
It works, except that it only displays the first value in
cia_notes.ID_Note in a particular cell. For example, consider
the
following example where there are two notes listed for the
U.S. in table
cia_notes...
ID_Name \ ID_Note
can \ Pop
mex \ Ppl
usa \ Pop
usa \ Ppl
My web page might display the following:
Name \ Population \ Notes
Canada \ 60 million \ Pop
Mexico \ 80 million \ Ppl
United States \ 300 million \ Pop
When I want the last row to look like this:
United States \ 300 million \ PopPpl
I want to use MySQL's SEPARATOR function to insert commas and
a PHP
str_replace to convert it to superscripts, like this:
United States \ 300 million \ 1,2
At any rate, below is the script I came up with to tap into
the
GROUP_CONCAT function. All the data in my table displays
correctly,
except that it now displays no notes (ID_Note) at all. Thanks
for any tips.
SELECT CP.ID
, CP.ID_Name
, CP.Pop
, CP.Pop2
, CP.AgeMed
, CP.Age0
, CP.Age15
, CP.Age65
, CP.Sex
, CP.LifeExp
, CP.PopGrowth
, CP.LitTotal
, GG.IDArea, GG.Name
, DT.ppl_notes
FROM cia_ppl CP
LEFT JOIN gw_geog GG ON GG.IDArea = CP.ID_Name
LEFT OUTER JOIN (
select ID_Name
, GROUP_CONCAT(ID_Note) as ppl_notes
from cia_notes
where Cat = "Ppl"
group
by ID_Name
) as DT
ON DT.ID_Name = CP.ID_Name
WHERE CP.Pop != 0
and CP.ID_Name != 'ear'
AND CP.ID_Name != 'eru'
GROUP BY GG.Name
ORDER BY CP.ID
www.geobop.org - Family Websites
www.invisible-republic.org - Adult political websites (Mature
adults only)this prod_id to the prim key.
-----------^^
"Field 'prodid' doesn't have a default value"
-------------^
Typo?
Murray --- ICQ 71997575
Adobe Community Expert
(If you *MUST* email me, don't LAUGH when you do so!)
==================
http://www.projectseven.com/go
- DW FAQs, Tutorials & Resources
http://www.dwfaq.com - DW FAQs,
Tutorials & Resources
==================
"Deon H" <[email protected]> wrote in message
news:[email protected]..
> Hi there. (I know this is propably not the right forum
to ask here, but
> the other forums don't help a lot. Please help me.)
>
>
>
> I have been using phpMyAdmin for a couple of years now
and simply love
> it.
> I have just created a new DB with 6 fields of which the
1st one is
> named: prod_id.
> type: smallint
>
> The rest of the fields are the default settings as
usual. I have changed
> this prod_id to the prim key.
>
> For some reason which I cannot figure out why, does not
show under
> "extra" as "auto_increment".
>
> I have double chacked the other db's I have created
exactly as I have
> done this one, and there is says "auto_increment".
> When I now try to add a record to the DB, I get this
error: "Field
> 'prodid' doesn't have a default value"
>
> Please advise where I am doing something wrong.
>
> Sincere regards,
> Deon
Maybe you are looking for
-
PP-MM-FI integration for Non-Stock material consumption
The client is expecting a simple solution for a Std SAP process which is LIKE subcontracting....but actually not. The requirement is to set up a process of external operations using a NonStock (NLAG) material ( which will have no physical stock updat
-
IMac crashes many times a day even after reinstall and lookupd fixes. Help?
Hi, Two days after receiving my recertified iMac G5 rev. B 2gHz from Apple, I started experiencing the frequent freezes and crashes that have plagued so many others, mainly when I was on the Web, but not always. It has happened in nearly every applic
-
Importing classes, package, Jamlab, JAMA
Hello: I am using, inside a JSP, a modified version of this code --> http://www.developer.com/java/other/article.php/806711, which uses a package named JAMA and Jamlab(to work with matrix) --> http://www.developer.com/java/other/article.php/762441 It
-
Look And Feel (branding) change in web application?
I am doing a research and I neeed advice from people who have more experience in dynamic customizing of java web applications. In my custom case I have a simple login page with some images, labels and so on. The idea is to implement it in such a way
-
URLClassLoader - with JAR Files- - - Please Help
Hi all, I have two seperate JAR files which contain same files but different progressive versions.JAR 1 is version V1 and JAR 2 is Version V1.1 I have a program which loads classes from these two JARS and runs certain comparsions on them.CODE IS SHOW