我有两个电话叫"tipo_hh"和"tipo_hh_historial".
我需要在两个表之间建立连接,其中"id"在两个表中都是相同的.但我需要为表格"tipo_hh"中的每个"id"选择表"tipo_hh_historial"上的"valor",其条件是带有"fecha_cambio"和"hora_cambio"maxima的记录.
"id"是表"tipo_hh"中的主键和自动增量
像这样的东西.
这是表"tipo_hh"
id nombre
1 Reefer
2 Lavados
3 Dry
4 Despacho
Run Code Online (Sandbox Code Playgroud)
这是表"tipo_hh_historial"
id valor fecha_cambio hora_cambio
1 1.50 27/06/2013 19:15:05
1 5.50 27/06/2013 19:19:32
1 5.50 27/06/2013 19:20:06
1 2.50 27/06/2013 21:03:30
2 4.66 27/06/2013 19:15:17
2 3.00 27/06/2013 19:20:22
3 5.00 27/06/2013 19:20:32
4 1.50 27/06/2013 19:20:50
Run Code Online (Sandbox Code Playgroud)
我需要这个:
id nombre valor
1 Reefer 2.50
2 Lavados 3.00
3 Dry 5.00
4 Despacho 1.50
Run Code Online (Sandbox Code Playgroud) 我有表单,我想在提交时验证日期字段,我正在使用表单生成器,我该怎么做(角度方式)?另一个问题为什么我看不到日期字段中的值published_date?我试图搜索,但找不到输入日期字段的解决方案。
unamePattern = /^\d{1,2}\/\d{1,2}\/\d{4}$/;
ngOnInit() {
this.book =
{
id: 55,
author_name : "vv",
published_date : new Date('01/02/2018'),
title : "cc"
};
this.form = this.formBuilder.group({
title : ['', Validators.required],
author : ['', Validators.required],
datePublish: ['', Validators.pattern(this.unamePattern)],
}
);
}Run Code Online (Sandbox Code Playgroud)
<input
[(ngModel)]="book.published_date"
id="dateOfBirth"
class="form-control"
placeholder="yyyy-mm-dd"
name="dp"
ngbDatepicker
formControlName="datePublish"
#dp="ngbDatepicker">
<div class="input-group-append">
<button class="btn btn-outline-secondary" (click)="dp.toggle()" type="button">
<i class="fa fa-calendar" aria-hidden="true"></i>
</button>
</div>Run Code Online (Sandbox Code Playgroud)
有没有办法为 MySQL 服务器中的每个数据库设置密码。如果有,给一些建议。
在这种情况下,我有三个主表:类别,板和权限.类别和董事会表格非常明显.权限表包含的行将确定是否允许用户读取板内的线程,在板内创建线程,回复板内的线程,或者调整板内的线程和帖子.在表中,用户对每个操作的能力由0(关闭或假)或1(开启或真实)指示.这些基于用户所属的成员组.
我想要做的是创建一个选择类别的查询.它应该只选择具有用户可以读取的板的类别.基本上,如果某个类别没有用户可以阅读的任何板,则不会选择它.如果该类别甚至只有一个用户可以阅读的板,它将被选中.
下一个查询是选择用户可以读取的特定类别中的板.基于与上述相同的原则.显示一个用户无法阅读的电路板有什么意义,让他们在点击链接后找到它?
我自己从未真正创建过这样复杂的查询,所以我甚至不知道从哪里开始.如果你能帮帮我,我真的很感激.
所以,我决定试一试,这就是我想出来的:
$query = "
SELECT
b.category_id, b.board_id, b.position,
p.group_id, p.board_id, p.read
FROM forum_boards AS b
INNER JOIN forum_permissions AS p ON (
p.board_id = b.board_id,
p.group_id = 1,
p.read = 1
)
WHERE b.category_id = ".$category_id."
ORDER BY b.position";
请注意,这是用于获取用户可以阅读的特定类别内的板的查询.它目前正在返回以下错误,我无法弄清楚原因.
Operand should contain 1 column(s)

我尝试在wordpress插件中添加多个上传选项,我在插件中重复了这段代码(两次),只更改了id名称.
<script language="JavaScript">
jQuery(document).ready(function($) {
jQuery('#upload_image_button').click(function() {
formfield = jQuery('#upload_image').attr('name');
tb_show('', 'media-upload.php?type=image&TB_iframe=true');
return false;
});
window.send_to_editor = function(html) {
imgurl = jQuery('img', html).attr('src');
jQuery('#upload_image').val(imgurl);
tb_remove();
};
});
</script>
<input id="upload_image" style=" margin-left:303px;" type="text" size="36" name="upload_image_template" value="<?php echo get_option('upload_image_template'); ?>" />
<input id="upload_image_button" type="button" value="Browse" />
Run Code Online (Sandbox Code Playgroud)
每当我尝试上传媒体帧的图像并且上传过程成功完成时.但Insert Into Post获取正确的URL但粘贴在不同的输入框中.例如:
1) [text box1] [browse Button]
2) [text box2] [browse button]
Run Code Online (Sandbox Code Playgroud)
当我使用文本框一上传图像时,[insert post]该图像路径显示在[text box 2]
我不确定问题是我的还是该脚本不支持多文件上传选项.
我的 MySQL 脚本
DROP TABLE IF EXISTS `informationposting`;
CREATE TABLE `informationposting` (
`Id` int(11) NOT NULL AUTO_INCREMENT,
`StexId` varchar(9) DEFAULT NULL,
`TargetContinent` int(11) DEFAULT NULL,
`TargetCountry` int(11) DEFAULT NULL,
`TargetCity` varchar(15) DEFAULT NULL,
`InfoType` int(11) DEFAULT NULL,
`WebsiteLink` varchar(30) DEFAULT NULL,
`InfoPost` varchar(200) DEFAULT NULL,
`PostingDate` datetime DEFAULT NULL,
`ExpiryDate` datetime DEFAULT NULL,
`Title` varchar(100) DEFAULT NULL,
`NameOfOwner` varchar(45) DEFAULT NULL,
`RegistrationTypeIdOfOwner` int(11) DEFAULT NULL,
PRIMARY KEY (`Id`),
KEY `FK_InformationUser_Id_idx` (`StexId`),
FULLTEXT KEY `InfoPost` (`InfoPost`),
FULLTEXT KEY `NameOfOwner` (`NameOfOwner`),
FULLTEXT …Run Code Online (Sandbox Code Playgroud) 我希望显示£2.00而不是£2或£3.50而不是£3.5.
这些数字可以说price是DOUBLE在MySQL数据库中定义的.如何强制MySQL或PHP显示两位小数?
非常感谢!
我正在建立一种方式来形成我的用户"喜欢"一个帖子.
我会有一些喜欢帖子的用户:
$user_ids = array(60, 61, 62, 63);
Run Code Online (Sandbox Code Playgroud)
然后一个帖子会有一个post_meta,当点击帖子上的"喜欢"按钮时会保存用户ID,如下所示:
// Build array of user IDs that have liked this post
$likes = array(61, 62);
// Save array
update_post_meta($post->ID, likes, $likes);
Run Code Online (Sandbox Code Playgroud)
那么如何才能返回用户喜欢的所有帖子.这就是我目前正在做的事情,但这不起作用.
$args = array(
'post_type' => 'post',
'post_status' => 'publish',
'posts_per_page' => -1,
'orderby' => 'rand',
'meta_query' => array(
'relation' => 'AND',
array(
'key' => 'likes',
'value' => $user_ids,
'compare' => 'IN'
)
)
);
$posts = get_posts($args);
Run Code Online (Sandbox Code Playgroud)
这应该返回帖子'likes'meet中保存有'60,61,62,63'的所有帖子.但它返回0结果.
现在,我认为这是因为WordPress在将数组保存在post_meta时序列化数组.
那么,我该怎么做这样的查询呢?它甚至可能吗?也许我必须使用$ wpdb类.
谢谢!
您的SQL语法有错误; 检查与您的MySQL服务器版本对应的手册,以便在'WHERE j附近使用正确的语法.id_customer第4行= 1'
SELECT j.`id_customer`, j.`id_order`, m.`id_shop`
FROM `ps_orders` j
LEFT JOIN `ps_order_detail` m
WHERE j.`id_customer` = 1
Run Code Online (Sandbox Code Playgroud)
这是从prestashop php中的原始代码生成的,如果打开详细的错误纠正-------
foreach ($result as $key)
{
$customer_id_is = 1;
$product_id_is = 5;
$result2 = Db::getInstance()->executeS(
'SELECT j.`id_customer`, j.`id_order`, m.`id_shop`
FROM `'._DB_PREFIX_.'orders` j
LEFT JOIN `'._DB_PREFIX_.'order_detail` m
WHERE j.`id_customer` = '.$customer_id_is.'
');
}
Run Code Online (Sandbox Code Playgroud) 小查询问题,我有桌子:
id | user_id | paper_update
------------------------------
1 | 1 | 30-5-2011
2 | 2 | 30-5-2012
3 | 3 | 30-5-2012
4 | 1 | 30-5-2013
5 | 2 | 30-5-2013
6 | 3 | 30-5-2014
7 | 4 | 30-5-2014
8 | 5 | 30-5-2014
9 | 5 | 30-5-2015
10 | 5 | 30-5-2016
11 | 1 | 30-5-2010
-------------------------------
Run Code Online (Sandbox Code Playgroud)
我要做的是只选择记录paper_update之间的最大记录user_id,实际上我想要按user_id最大值分组paper_update.所以对于这个表,它将返回:
id | user_id | paper_update
------------------------------
4 | …Run Code Online (Sandbox Code Playgroud)