[Solved] Fetch teacher and subject wise details in mysql and php

Why don’t you combine both into a single SQL? SQL query to fetch the details of each teacher in a searched institute and their subject strength where institute is equal to searched institue. Show only that teacher details which is not having strength of 25 students in each subject where institue is equal to searched … Read more

[Solved] PHP + MySQL Interval query last 1 month with sum problem

You don’t have $row[“mbsent”] in your SELECT clause of your query. Perhaps you meant: $sql = “SELECT SUM(mbsent) AS summ, mbsent FROM data WHERE datum < DATE_ADD(NOW(), INTERVAL -1 MONTH) AND user=”csib” GROUP BY mbsent”; But that doesn’t make any sense either… so not sure what you are going for here. Also, I think you … Read more

[Solved] CONCAT in stored procedure returns null

The documentation says CONCAT() returns NULL if any argument is NULL. This is demonstrated by this example: http://sqlfiddle.com/#!2/d41d8/47037 You can find some documentation on working with nulls here: http://dev.mysql.com/doc/refman/5.0/en/working-with-null.html 2 solved CONCAT in stored procedure returns null

[Solved] Inserting months and updating it with Amount

Here’s an example script on how to do it as I explained in the comments before. All you have to do is adept your database and output to it: <?php $costs = 180; //Total costs $month_costs = 30; //Costs per month $paid = 80; //Paid first & second month + 10 dollar / euro extra … Read more

[Solved] How to get Joomla users data into a json array [closed]

You are overwriting the $id variable and then you are not using it… It seems there’s a mess in there with the $title, $name and $id variables. Try this: <?php $sql = “SELECT * FROM `jos_users` LIMIT 0, 30 “; $response = array(); $posts = array(); $result=mysql_query($sql); while($row=mysql_fetch_array($result)) { $id=$row[‘id’]; //change here $name=$row[‘name’]; //change here … Read more

[Solved] Mysql functions in zend 2

/* DB Adapter get and SQL object create */ $adapter = GlobalAdapterFeature::getStaticAdapter(); $sql = new \Zend\Db\Sql\Sql($adapter); /* Select object create */ $select = new \Zend\Db\Sql\Select(); $select->from(‘states’); $select->where->addPredicate( new \Zend\Db\Sql\Predicate\Expression( ‘TRIM(LOWER(state_name)) = ?’, ‘noida’ ) ); /* Select object convert to string and execute */ $queryString = $sql->getSqlStringForSqlObject($select); $result = $adapter->query($queryString, Adapter::QUERY_MODE_EXECUTE); 1 solved Mysql functions … Read more

[Solved] How to get non grouped-by columns in SQL statement (similar to in MySQL)

Below is for BigQuery Standard SQL and as simple as below #standardSQL SELECT ANY_VALUE(first_name) first_name FROM `project.dataset.table` GROUP BY age As you can see you were missing just aggregation function – it can be any – MAX, MIN, etc. I’ve chosen ANY_VALUE as an example You can test, play with above using some simplified dummy … Read more

[Solved] How can I add “ON UPDATE CURRENT_TIMESTAMP” on a column at table creation or by alter table withoud defining its default value

ALTER TABLE t1 MODIFY COLUMN c1 TIMESTAMP NULL — the opposite is NOT NULL, which is implicitly set on timestamp columns DEFAULT NULL — no default value for newly-inserted rows ON UPDATE CURRENT_TIMESTAMP; 0 solved How can I add “ON UPDATE CURRENT_TIMESTAMP” on a column at table creation or by alter table withoud defining its … Read more

[Solved] how to get result based on 10 minutes interval in mysql

i have found the solution by below query. select a.time_column,group_concat(a.destination order by ct desc) from (select case when time between ’00:00:00′ and ’00:10:00′ then ’00:10:00′ when time between ’00:10:01′ and ’00:20:00′ then ’00:20:00′ when time between ’00:20:01′ and ’00:30:00′ then ’00:30:00′ else ’00:00:00′ end as time_column , destination , count(destination) ct from click group by … Read more