where

Is there a way to show a WHERE clause just for one field in MySQL?

前提是你 提交于 2019-12-27 16:09:29
问题 I do have some courses, to which students can enroll. There's a users table (usuarios), a courses (cursos) table and a third table that shows each student enrollment (cursosUsuarios), like this: CREATE TABLE usuarios( userID int unsigned not null auto_increment primary key, userName char(50) null, )ENGINE=InnoDB DEFAULT CHARSET=utf8; CREATE TABLE cursos ( cursoID int unsigned not null auto_increment primary key, nombreCurso char(100) not null, estadoCurso char(50) not null, )ENGINE=InnoDB

Is there a way to show a WHERE clause just for one field in MySQL?

醉酒当歌 提交于 2019-12-27 16:09:05
问题 I do have some courses, to which students can enroll. There's a users table (usuarios), a courses (cursos) table and a third table that shows each student enrollment (cursosUsuarios), like this: CREATE TABLE usuarios( userID int unsigned not null auto_increment primary key, userName char(50) null, )ENGINE=InnoDB DEFAULT CHARSET=utf8; CREATE TABLE cursos ( cursoID int unsigned not null auto_increment primary key, nombreCurso char(100) not null, estadoCurso char(50) not null, )ENGINE=InnoDB

C# generic “where constraint” with “any generic type” definition?

社会主义新天地 提交于 2019-12-27 13:36:35
问题 Let me give example: I have some generic class/interface definition: interface IGenericCar< T > {...} I have another class/interface that I want to relate with class above, for example: interface IGarrage< TCar > : where TCar: IGenericCar< (**any type here**) > {...} Basically, I want my generic IGarrage to be dependent on IGenericCar , regardless if it's IGenericCar<int> or IGenericCar<System.Color> , because I don't have any dependency to that type. 回答1: There are typically 2 ways to

Build dynamic WHERE clause in mySQL

随声附和 提交于 2019-12-25 18:58:55
问题 I have this code and it works great, if I just want to search by office name. However I need to be able to search by "Office and/or First Name and/or Last Name", any combination of the three. $firstName = $_POST["firstName"]; $lastName = $_POST["lastName"]; $officeName = $_POST ["officeName"]; $query = "SELECT e.*, e.id emp_id, o.* "; $query .= "FROM employee_data e, office o, employee_office_pivot p "; $query .= "WHERE 1=1 AND e.id=p.employee_id AND p.office_id=o.id AND o.office_name= '".

MySQL select distinct where in all

孤人 提交于 2019-12-25 18:37:08
问题 I have a table products and a table tags which both have these fields: id | name 1 | chair 2 | table And a linking table product_tags: id | productId | tagId 1 | 1 | 1 2 | 1 | 2 3 | 2 | 1 4 | 2 | 2 5 | 2 | 3 6 | 2 | 4 Products are displayed in a search result and can be narrowed down if the user ticks some of the tags. Therefore I need to have a query that returns the list of products that have all of the selected tags in product_tags. For example in my tables above if the user had ticked

Laravel 5 eloquent with whereHas more than 3. How to?

我怕爱的太早我们不能终老 提交于 2019-12-25 17:04:10
问题 it seems that it does not work, when I'm using "with" and function inside it and later trying to use "has" function. Here's the code, it should be easier to understand: $users = Users::where("active","=", "1")->with(['photos' => function($q){ $q->where('type','!=', 2); }])->has('photos', '>', 3)->paginate(8); } It seems, that it should return user ONLY if he has 3 photos which are NOT of type 2. But it doesn't care about "where" clause and return it without checking to the type. How can I

Laravel 5 eloquent with whereHas more than 3. How to?

谁说我不能喝 提交于 2019-12-25 17:03:48
问题 it seems that it does not work, when I'm using "with" and function inside it and later trying to use "has" function. Here's the code, it should be easier to understand: $users = Users::where("active","=", "1")->with(['photos' => function($q){ $q->where('type','!=', 2); }])->has('photos', '>', 3)->paginate(8); } It seems, that it should return user ONLY if he has 3 photos which are NOT of type 2. But it doesn't care about "where" clause and return it without checking to the type. How can I

Use case in where clause [duplicate]

时间秒杀一切 提交于 2019-12-25 11:56:15
问题 This question already has answers here : “CASE” statement within “WHERE” clause in SQL Server 2008 (11 answers) Closed 2 years ago . I am trying to add case statement to where condition in a query. My query looks like below- select * from table_name where if(id==1) then col1 = 0 else col1 is null As shown in above query I want to add col1 = 0 in where condition if id-==0 else I want col1 is null in where condition. I tried select * from table_name where case id =1 then (col1 = 0) else col1 is

variable not work in where clause php joomla

耗尽温柔 提交于 2019-12-25 08:02:07
问题 I have function and my function works good only I do not understand this: <?php // $category output is 23 when I echo $category; and there is no records ->where('d.category_id = ' . (int) $category) // also this method not work ->where('d.category_id = ' . $category) // but this method works ->where('d.category_id = 23') ?> this is full code: $category = $params->get('title'); //echo $category; public static function getSuggested($category) { $db = JFactory::getDBO(); $query = $db->getQuery

mysql 5.0 upgrade to 5.1 Match function

≡放荡痞女 提交于 2019-12-25 07:48:10
问题 I migrated a website's database from MySQL 5.0.95 to MySQL 5.1.59 When i try to do a search i get different results for example: When i search for "MTH" on the old database i get one result, but when i search on the new database for "MTH" i do not get any results However when i do a search for "accountents" i DO get the SAME results with both databases!?! so only some words shows different results, not all I narrowed it down to the "match" function from mysql. Anyone who has had the same