zoukankan      html  css  js  c++  java
  • PHP面试题

    一,PHP/MySQL编程

    1)某内容管理系统中,表message有如下字段

    id  文章ID

    title  文章标题

    content 文章内容

    category_id 文章分类id

    hits   点击量

    创建上表,写出MySQL语句

    c

    CREATE TABLE message(

    id int(32) PRIMARY KEY AUTO_INCREMENT,

    title varchar(255) NOT NULL DEFAULT '',

    content text NOT NULL,

    category_id tinyint(1) NUSIGNED NOT NULL DEFAULT 0,

    hits smallint(8) UNSIGNED NOT NULL DEFAULT 0)

    ENGINE=MYISAM DEFAULT CHARSET=UTF8;

    2) 同样上述内容管理系统:表comment记录用户回复内容,字段如下

    comment_id 回复id

    id                文章id,关联message表中的id

    comment_content  回复内容

    现通过查询数据库需要得到以下格式的文章标题列表,并按照回复数量排序,回复最高的排在最前面

    CREATE TABLE comment(

      comment_id int primary key auto_increment,

      id int not null,

      comment_content text not null

    )ENGINE=MYISAM DEFAULT CHARSET=UTF8;

    SELECT m.id,m.title,m.hits,COUNT(c.comment_is) AS comment_sum FROM message m LEFT JOIN comment c ON m.id=c.id ORDER BY comment_sum DESC LIMT 0,20;

    c

    CR

  • 相关阅读:
    动态规划_leetcode416
    动态规划_leetcode377
    基础整理
    super使用简介
    PHP替换指定字符串
    yii安装redis扩展(Windows)
    PHP多维数组去重
    git pull
    vue页面部署并移除url里面的#号
    fatal: refusing to merge unrelated histories(git pull)
  • 原文地址:https://www.cnblogs.com/liukongjun/p/4969709.html
Copyright © 2011-2022 走看看