I tried this but only got a syntax error:
<?php
$a = true;
$str = <<< EOF
{$a ? 1 : 2}
EOF;
echo $str;
Is it possible to use such kind of conditional statement inside heredoc?
For example I have:
create table a (i int);
Assume there are 10k rows.
I want to count 0's in the last 20 rows.
Something like:
select count(*) from (select i from a limit 20) where i = 0;
Is that possible to make it more efficient? Like a single SQL statement or something?
PS. DB is SQLite3 if that matters at all...
I am looking to execute this statement via Zend Framework. As I understand it, I can use Zend_Db_Select. Is it possible to use Zend_Db_Table?
Three tables: classes, students, and class_students
select classes.name, students.student_id, students.fname, students.lname from students, classes, class_students where class_students.student_id=students.student_id AND class_students.class_id=classes.class_id;
I have some code from a function
subl $24, %esp
movl 8(%ebp), %eax
cmpl 12(%ebp), %eax
Before the code is just the 'ENTER' command and afterwards there's an ifstatement to return 1 if ebp eax or 0 if it's less. I'm assuming cmpl means compare, but I can't tell what the concrete values are. Can anyone tell me what's happening?
In mysql, how do I get the primary key used for an insert operation, when it is autoincrementing.
Basically, i want the new autoincremented value to be returned when the statement completes.
Thanks!
The "Sleep" command as stated in many places over the internet (including here on this forum) DOES NOT WORK. Is it now an obsolete command?
I am writing the VBScript code like this:
sub button1_onclick()
Wscript.Sleep 1000
div1.innerHTML = textbox1.value
end sub
It should wait 1 second and then execute that simple command. This is an utterly simple statement but it does not work. Plain and simple. It comes up with an error every time saying:
Object Required: 'Wscript'
When I say, msg.appendTo(ele.parent().next()), the msg successfully gets appended to a <p> with class=foo
How can I specify it explicitly in the statement?
I tried msg.appendTo(ele.parent().next().find('.foo'));
but it doesn't work
Consider the following Java source:
if( agents != null ) {
for( Iterator iter = agents.keySet().iterator(); iter.hasNext(); ) {
// Code that uses iter.next() ...
//
}
}
The agents is a HashMap.
Why does the for statement sometimes throw a NullPointerException?
Thank you.
As I am a MySQL newbie. What does PARTITION mean in this MySQL statement?
CREATE TABLE employees (
id INT NOT NULL,
fname VARCHAR(30),
lname VARCHAR(30),
hired DATE NOT NULL DEFAULT '1970-01-01',
separated DATE NOT NULL DEFAULT '9999-12-31',
job_code INT NOT NULL,
store_id INT NOT NULL
)
PARTITION BY RANGE (store_id) (
PARTITION p0 VALUES LESS THAN (6),
PARTITION p1 VALUES LESS THAN (11),
PARTITION p2 VALUES LESS THAN (16),
PARTITION p3 VALUES LESS THAN (21)
);
I have a column called "menu_order" which has no default value. When I select the contents of this column using the following select statement:
SELECT * FROM categories ORDER BY menu_order ASC
It lists the category items that have nothing as their menu order first and then the one's that have 1's and 2's and 3's. Is there any way to prevent SQL from take nothing to come before numbers when I am trying to list things in order?
So for example, if I have:
cat_name | menu_order
----------------------
Lunch | 1
Dinner |
And I perform my query, the output should be:
Lunch Dinner
Not:
Dinner Lunch
hi,
I have the following code inside the .h file and I'm not sure what does the assignment statement do and how is it called properly?
virtual void yield() = 0;
I thought that the function returns a value of 0 by default but since this function returns void I am a little bit confused. Can anyone comment on this and maybe say how can I refer to this assignment, I mean how is it called in C++ jargon?
Thanks.
I'm in the process of creating an SSIS package on a server (server1) that looks at the data in a sql db on another site (server2) and copies relevant rows across.
The SQL statement required is:
SELECT *
FROM server2.ordersTable
WHERE
OrderID Not In (SELECT OrderID FROM server1.ordersTable
This selects data from server1 which isn't in the table on server2 (based on order id)
I then need to insert the result into a table on server1
How would I approach this? What components do I need etc...?
I have a script. I would like to give this script a quiet mode and a verbose mode.
This is the equivalent of:
if $verbose
then
redirect="> /dev/null"
fi
echo "Verbose mode enabled" $redirect # This doesn't work because the redirect isn't evaluated.
I'd really like a better way of doing this than writing if-elses for every statement affected.
eval could work, but has obvious side effects on other variables.
Assume I have the following:
unsigned int *start;
unsigned int total;
#define OFF_MASK (1 << 31)
#define ON_MASK (~(1 << 31))
if (!(*start & OFF_MASK) && ((*start & ON_MASK) >= total)))
How do I change the above ifstatement so that it makes just one comparison like this:
if (*start >= total)
What was the most stupid code mistake you have ever made that had great consequences, e.g. you were fired?
For example, a friend of mine wrote a cycle with conditional statement for break that was never true, which caused one high-loaded site to hang up for the whole night.
Hi,
I have a table in which I want a dynamic image to load in at the left-hand side. The table needs to use an IFstatement to select the appropriate image from the "Resources" folder, and needs to be based upon [dog types].
The [dog types] is extracted from an RSS feed, and so the image in the table cell needs to match the each cell's [dog types] tag.
I suspect I need to use - (UIImage *)imageForTypes:(NSString *)types { to do such a thing.
Thanks.
I am trying to figure out how to create an 'if' statement that uses a time value as a condition. For example:
if (time <= 10:00) {
score = 3;
} elseif (time <= 20:00) {
score = 5;
} else {
score = 9;
}
I know that a string of "5:23" cannot be compared this way but I don't think I can just turn a string value like that directly into an integer. Any thoughts?
Hey all,
I'm practicing Jquery and I've written this simple Jquery statement:
var someText = $("table tr td").text();
Should this not return all text of td elements found within tr's that are found within tables? How do I fix this? Currently when I run this, it says that table tr td is null, but I have a table on the page I'm testing on.
Thanks!
Why does the following code fail to compile while changing the case statement to
case ENUM1: doSomeStuff();
works?
public enum EnumType
{
ENUM1, ENUM2, ENUM3;
void doSomeStuff()
{
switch(this)
{
case EnumType.ENUM1: doSomeStuff();
}
}
}
An insert statement with a large number of values returns 'Error converting data type varchar to numeric.'
How can I find which value actually triggers the error?
MS SQL Server 2008 is used.
I have following statement in one of the oracle SP:
OPEN CUR_NUM FOR
SELECT RTRIM(LTRIM(num)) as num
FROM USER WHERE USER_ID = v_user_id;
When the above does not return anything the SP result just has no column name in it. But I'd like the cursor to still have num column with some default value like NOTHING when no data is found.
Is this doable ?
when I input
mysql -u root -p XXXX dbname < c:/filename.sql
alway get this error "error 1064 <42000:" you have an error in your SQL suntax; check the manual that corresponds to your MySql server version for the right syntax to use near .....
what is wrong with this statement?
Lets assume my database table structure is something like
| items | weight |
|============|==========|
| item_1 | 50 |
| item_2 | 90 |
| item_2 | 45 |
| item_2 | 60 |
| item_3 | 40 |
In the select statement, I want to show an item only for once with the highest weight also ordered by height. So the result should be :
| items | weight |
|============|==========|
| item_2 | 90 |
| item_1 | 50 |
| item_3 | 40 |
I tried something like
SELECT DISTINCT items, weight FROM mytable ORDER BY weight DESC
but it didn't work because the results are actually distinct.
How can I make that selection?