I'm working on a mock exam paper at the moment, however I have no set of correct answers and I'm not sure what the correct answer of this SQL query is.
Given a table:
foo, bar
a , 1
b , 3
a , 2
c , 1
and the query:
SELECT foo, sum(bar)
FROM table
GROUP BY foo
The two ways I can see this going are either:
a 3
a 3
b 3
c 1
or
a 3
b 3
c 1
Thanks.
I have a question about using subqueries in an Update statement. My example:
UPDATE TRIPS
SET locations = city + ', ' FROM (select Distinct city
from poi
where poi.trip_guid = trips.guid)
Is it possible to refer to main table value (trips.guid) in subqueries?
When i try to use trips.guid I get the error:
"The multi-part identifier "trips.guid" could not be bound."
I have 2 tables:
Table A: code | name
Table B: barcode | name
Table B has full barcode and name, Table A has only code.
I need to run update query that fill name in Table A.
I tried something like:
update A set name = (select top 1 Name from B where B.Code = mid(A.Barcode,1,8))
but it doesn't work.
var victim = System.IO.Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Victim.dll");
var assy = AppDomain.CurrentDomain.Load(System.IO.File.ReadAllBytes(victim));
var types = from x in assy.GetTypes()
where x.Name.StartsWith("AwesomePage")
select x;
var pageType = types.First();
page = Activator.CreateInstance(pageType);
this.Content = page;
Could someone tell me why a dll file would be targeted?
i have an ajax script that check if the user name is available or not, but it keeps taking the newest user name and the rest are out
$result = mysql_query("Select username from customer");
while ($row = mysql_fetch_array($result)){
$existing_users=array(''.$row['username'].',');
}
i know i am doing something worng
Hi
In my mode I am selecting a field as
$query1 = $this->db->query("SELECT dPassword
FROM tbl_login
WHERE dEmailID='[email protected]'");
How to return dpassword as a variable to my controller
I tried this way return dpassword;
Hello everybody
I have a user entity who contains a one to many relationship with a role entity
So with this linq expression :
from user in USER_TABLE.Include("USERROLE_TABLE")
order by user.Name
select user
I can get users with related roles as a child.
My problem is that i want to get roles of each user ordered alphabetically.
How can i do that ? I googled a lot and don't find anything
Thank's by advance !
I know how to create a row in Table B for every row in Table A:
INSERT INTO [dbo].[TableB] SELECT 0, 5, 3, [TableAColumn] FROM [dbo].[TableA]
But I need to also put the ID of each new TableB row into a column in TableA, and I can't figure out how to do that.
In Blackberry device if we go to
Options --- Date/Time ----Use Network Time -- No
Now when we select date or time a very stylish selector opens up that
enables user to set date and time.
Can i use such control in my app.
I saw such in Storm 9530
Any idea please help!!!!!!!!!!!!!!!!
I have a table which has a bunch of columns but the two relevant ones are:
Due_Amount MONEY
Bounced_Due_Amount MONEY
I have a SQL query like the following
SELECT * FROM table WHERE (Due_Amount 0 OR Bounced_Due_Amount 0)
Would the best index to put on this table for SQL Server 2008 be an index which includes both columns in the index, or should I put an separate index on each column?
UPDATE polls_options SET `votes`=`votes`+1, `percent`=ROUND((`votes`+1) / (SELECT voters FROM polls WHERE poll_id=? LIMIT 1) * 100,1)
WHERE option_id=?
AND poll_id=?
Don't have table data yet, to test it properly. :)
And by the way, in what type % integers should be stored in database?
Thanks for the help!
The first one below works, but, just wanted to see if there's a better way...
If I'm trying to find all records that start with 'C' with either a flag of 2 or a status of 9, do I need to incorporate the 'C' criteria twice?
i.e.,
"SELECT * FROM mytable WHERE name like 'C%' AND flag = 2 OR name like 'C%' AND status = 9"
Or, is there a way quicker way to write it so that I only need to set 'C%' once?
On login:
$result = mysql_query("SELECT `id`, `username`, `email` FROM `users`
WHERE `username` = '$username'
AND `password` = '$passwd'");
$userdata = array('id','username','email');
$_SESSION['user'] = mysql_result($result, 0, $userdata);
And when i want to print the users username
echo $_SESSION['user']['username']
it only prints the first letter :/
whats wrong`?
is there a way to go from a MetaTable to an instance of an entity type so it can be queried with LINQ? What I want to do is this:
MetaTable table = GridDataSource.GetTable ();
var entity = table.GetInstanceOfEntity();
var test = (from t in entity select t).ToList();
where table.GetInstanceOfEntity() is something that I'm not sure how to implement.
Thank you
I have select, insert, update and delete query.
if i have to write all query in same store procedure that is good for performance or i should write all query in separate store procedure?
It starts to bore me that I always have to ask questions about trifles.
I simply need a list of all plugged in USB devices and have the user select one to let the console application receive any data the USB device sends.
I can then start playing around with the data in my program.
I don't want to use library's, only standard C++ functions, and the program should work in Windows 98.
Hi guys, I've got this table
CREATE TABLE `subevents` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`title` varchar(150) DEFAULT NULL,
`content` text,
`class` tinyint(4) NOT NULL DEFAULT '1',
PRIMARY KEY (`id`)
) ENGINE=MyISAM
Each row can have a different value in the 'class' field.
I'd like to select any number of rows, ordered randomly, as long as the sum of the values in the 'class' field is equal to 100.
How could I accomplish it directly in the MySQL query without doing it later in PHP?
Thanks everybody!
I am have trouble with a summary not showing up. I am supposed to modify a previous Java assignment by by adding an array of objects. Within the loop, instantiate each individual object. Make sure the user cannot keep adding another Foreign conversion beyond your array size.
After the user selects quit from the menu, prompt if the user want to display a summary report. If they select ‘Y’ then, using your array of objects, display the following report:
Item Conversion Dollars Amount
1 Japanese Yen 100.00 32,000.00
2 Mexican Peso 400.00 56,000.00
3 Canadian Dollar 100.00 156.00
etc.
Number of Conversions = 3
There are no errors when I compile..but when I run the program it is fine until I hit 0 to end the conversion and have it ask if i want to see a summary. This error displays:
Exception in thread "main"
java.lang.StringIndexOutOfBoundsException: String index out of range: 0
at java.lang.String.charAt(String.java:658)
at Lab8.main(Lab8.java:43)
my code:
import java.util.Scanner;
import java.text.DecimalFormat;
public class Lab8
{
public static void main(String[] args)
{
final int Max = 10;
String a;
char summary;
int c = 0;
Foreign[] Exchange = new Foreign[Max];
Scanner Keyboard = new Scanner(System.in);
Foreign.opening();
do
{
Exchange[c] = new Foreign();
Exchange[c].getchoice();
Exchange[c].dollars();
Exchange[c].amount();
Exchange[c].vertical();
System.out.println("\n" + Exchange[c]);
c++;
System.out.println("\n" + "Please select 1 through 4, or 0 to quit" + >"\n");
c= Keyboard.nextInt();
}
while (c != 0);
System.out.print("\nWould you like a summary of your conversions? (Y/N): ");
a = Keyboard.nextLine();
summary = a.charAt(0);
summary = Character.toUpperCase(summary);
if (summary == 'Y')
{
System.out.println("\nCountry\t\tRate\t\tDollars\t\tAmount");
System.out.println("========\t\t=======\t\t=======\t\t=========");
for (int i=0; i < Exchange.length; i++)
System.out.println(Exchange[i]);
Foreign.counter();
}
}
}
I looked at line 43 and its this line: summary = a.charAt(0);
But I am not sure what's wrong with it, can anyone point it out? Thank you.
How to track the mouse position on the screen regardless of application.i.e. Whenever the user clicks or select something with mouse in any application, i want to display my own menu at that point itself.
Is there any way to get mouse position on the screen using c#?
Hi all,,,
I am trying to do a small thing, any 1 help me, I really appricciate...
I have a drop down menu,I want when I select the value, it will call the related data, which I am access with php+mysql, I dont want to jump to other page and show
i am using "beassistance validation" for my form and using tooltip plugin and it work fine except that positioning.
please have a look at this link and i upload my form to get an idea what i am talking about.
what i want is:
if my validation fails i want to display the message after the tooltip icon, but its displaying the message before the tooltip icon. please see here
here is the .css i am using:
validation .css
#aspnetForm
{
width: 670px;
}
#aspnetForm label.error
{
margin-left: 10px;
width: auto;
display: inline;
}
form.cmxform
{
width: 50em;
}
em.error
{
background: url("Images/unchecked.gif") no-repeat 0px 0px;
padding-left: 16px;
}
em.success
{
background: url("Images/checked.gif") no-repeat 0px 0px;
padding-left: 16px;
}
form.cmxform label.error
{
margin-left: auto;
width: 250px;
}
#aspnetForm label.error
{
background: url("Images/unchecked.gif") no-repeat 0px 0px;
padding-left: 16px;
padding-bottom: 2px;
font-weight: bold;
color: #EA5200;
}
#aspnetForm label.checked
{
background: url("Images/checked.gif") no-repeat 0px 0px;
}
em.error
{
color: black;
}
#warning
{
display: none;
}
<asp:Label runat="server" ID='Label8' >Start Date:</asp:Label>
<asp:TextBox ID="txtStartDate" runat='server' ></asp:TextBox>
<a style="cursor: hand" class="tooltip" title="Select the starting date of a visit, example 05/05/2010 (MM/DD/YYYY)!">
<img alt="" src="Scripts/JQuery/Tooltip/icon_tooltip.gif" style="width: 11px; height: 11px" /></a>
<p>
</p>
<asp:Label runat="server" ID='Label9' >End Date:</asp:Label>
<asp:TextBox ID="txtEndDate" runat='server' ></asp:TextBox>
<a style="cursor: hand" class="tooltip" title="Select the end date of a visit, example 05/06/2010 (MM/DD/YYYY)!">
<img alt="" src="Scripts/JQuery/Tooltip/icon_tooltip.gif" style="width: 11px; height: 11px" /></a>
tooltip.css
#tooltip{
position:absolute;
border:1px solid #333;
background:#f7f5d1;
padding:2px 5px;
color:#333;
display:none;
}
I created a query in Microsoft Access like the one below:
SELECT Deliverables.ID, Deliverables.Title, Deliverables.Summary, Deliverables.Header_Code, Deliverables.Header_Code.Value, Deliverables.Sort_order, Deliverables.Pillar, Deliverables.Pillar.Value, Deliverables.Misc_ID
FROM Deliverables
WHERE (((Deliverables.Pillar.Value)="Link Building"));
But my problem is that this query locks my fields and I cannot make changes to the table using the query view.
Any suggestions? I am using Microsoft Access 2007